Healthz   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 30
dl 0
loc 63
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getTimestamp() 0 3 1
A getId() 0 3 1
A __construct() 0 4 1
A getCreatedAt() 0 3 1
A setTimestamp() 0 5 1
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