src/Entity/Healthz.php
<?php
declare(strict_types = 1);
/**
* /src/Entity/Healthz.php
*
* @author TLe, Tarmo Leppänen <tarmo.leppanen@pinja.com>
*/
namespace App\Entity;
use App\Entity\Interfaces\EntityInterface;
use App\Entity\Traits\Uuid;
use DateTimeImmutable;
use DateTimeZone;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use OpenApi\Attributes as OA;
use Override;
use Ramsey\Uuid\Doctrine\UuidBinaryOrderedTimeType;
use Ramsey\Uuid\UuidInterface;
use Symfony\Component\Serializer\Annotation\Groups;
use Throwable;
/**
* @package App\Entity
* @author TLe, Tarmo Leppänen <tarmo.leppanen@pinja.com>
*/
#[ORM\Entity]
#[ORM\Table(
name: 'healthz',
)]
#[ORM\ChangeTrackingPolicy('DEFERRED_EXPLICIT')]
class Healthz implements EntityInterface
{
use Uuid;
#[ORM\Id]
#[ORM\Column(
name: 'id',
type: UuidBinaryOrderedTimeType::NAME,
unique: true,
)]
#[Groups([
'Healthz',
'Healthz.id',
])]
#[OA\Property(type: 'string', format: 'uuid')]
private UuidInterface $id;
#[ORM\Column(
name: 'timestamp',
type: Types::DATETIME_IMMUTABLE,
)]
#[Groups([
'Healthz',
'Healthz.timestamp',
])]
private DateTimeImmutable $timestamp;
/**
* @throws Throwable
*/
public function __construct()
{
$this->id = $this->createUuid();
$this->timestamp = new DateTimeImmutable(timezone: new DateTimeZone('UTC'));
}
#[Override]
public function getId(): string
{
return $this->id->toString();
}
public function getTimestamp(): DateTimeImmutable
{
return $this->getCreatedAt();
}
public function setTimestamp(DateTimeImmutable $timestamp): self
{
$this->timestamp = $timestamp;
return $this;
}
#[Override]
public function getCreatedAt(): DateTimeImmutable
{
return $this->timestamp;
}
}