|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types = 1); |
|
3
|
|
|
/** |
|
4
|
|
|
* /src/Entity/Healthz.php |
|
5
|
|
|
* |
|
6
|
|
|
* @author TLe, Tarmo Leppänen <[email protected]> |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace App\Entity; |
|
10
|
|
|
|
|
11
|
|
|
use App\Entity\Interfaces\EntityInterface; |
|
12
|
|
|
use App\Entity\Traits\Uuid; |
|
13
|
|
|
use DateTimeImmutable; |
|
14
|
|
|
use DateTimeZone; |
|
15
|
|
|
use Doctrine\DBAL\Types\Types; |
|
16
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
17
|
|
|
use OpenApi\Attributes as OA; |
|
18
|
|
|
use Ramsey\Uuid\Doctrine\UuidBinaryOrderedTimeType; |
|
19
|
|
|
use Ramsey\Uuid\UuidInterface; |
|
20
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
|
21
|
|
|
use Throwable; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Class Healthz |
|
25
|
|
|
* |
|
26
|
|
|
* @package App\Entity |
|
27
|
|
|
* @author TLe, Tarmo Leppänen <[email protected]> |
|
28
|
|
|
*/ |
|
29
|
|
|
#[ORM\Entity] |
|
30
|
|
|
#[ORM\Table( |
|
31
|
|
|
name: 'healthz', |
|
32
|
|
|
)] |
|
33
|
|
|
#[ORM\ChangeTrackingPolicy('DEFERRED_EXPLICIT')] |
|
34
|
|
|
class Healthz implements EntityInterface |
|
35
|
|
|
{ |
|
36
|
|
|
use Uuid; |
|
37
|
|
|
|
|
38
|
|
|
#[ORM\Id] |
|
39
|
|
|
#[ORM\Column( |
|
40
|
|
|
name: 'id', |
|
41
|
|
|
type: UuidBinaryOrderedTimeType::NAME, |
|
42
|
|
|
unique: true, |
|
43
|
|
|
)] |
|
44
|
|
|
#[Groups([ |
|
45
|
|
|
'Healthz', |
|
46
|
|
|
'Healthz.id', |
|
47
|
|
|
])] |
|
48
|
|
|
#[OA\Property(type: 'string', format: 'uuid')] |
|
49
|
|
|
private UuidInterface $id; |
|
50
|
|
|
|
|
51
|
|
|
#[ORM\Column( |
|
52
|
|
|
name: 'timestamp', |
|
53
|
|
|
type: Types::DATETIME_IMMUTABLE, |
|
54
|
|
|
)] |
|
55
|
|
|
#[Groups([ |
|
56
|
|
|
'Healthz', |
|
57
|
|
|
'Healthz.timestamp', |
|
58
|
|
|
])] |
|
59
|
|
|
private DateTimeImmutable $timestamp; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Healthz constructor. |
|
63
|
|
|
* |
|
64
|
|
|
* @throws Throwable |
|
65
|
|
|
*/ |
|
66
|
10 |
|
public function __construct() |
|
67
|
|
|
{ |
|
68
|
10 |
|
$this->id = $this->createUuid(); |
|
69
|
10 |
|
$this->timestamp = new DateTimeImmutable(timezone: new DateTimeZone('UTC')); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
2 |
|
public function getId(): string |
|
73
|
|
|
{ |
|
74
|
2 |
|
return $this->id->toString(); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
4 |
|
public function getTimestamp(): DateTimeImmutable |
|
78
|
|
|
{ |
|
79
|
4 |
|
return $this->getCreatedAt(); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
2 |
|
public function setTimestamp(DateTimeImmutable $timestamp): self |
|
83
|
|
|
{ |
|
84
|
2 |
|
$this->timestamp = $timestamp; |
|
85
|
|
|
|
|
86
|
2 |
|
return $this; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
5 |
|
public function getCreatedAt(): DateTimeImmutable |
|
90
|
|
|
{ |
|
91
|
5 |
|
return $this->timestamp; |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|