Passed
Push — master ( 9ff768...b736eb )
by Laurens
02:33
created

Category::getUpdatedBy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\IzettleApi\API\Product;
6
7
use DateTime;
8
use Ramsey\Uuid\Uuid;
9
use Ramsey\Uuid\UuidInterface;
10
11
final class Category
12
{
13
    private $uuid;
14
    private $name;
15
    private $etag;
16
    private $updatedAt;
17
    private $updatedBy;
18
    private $createdAt;
19
20 3
    public static function create(
21
        UuidInterface $uuid,
22
        string $name,
23
        string $etag = null,
24
        DateTime $updatedAt = null,
25
        UuidInterface $updatedBy = null,
26
        DateTime $createdAt = null
27
    ): self {
28 3
        return new self(
29 3
            $uuid,
30 3
            $name,
31 3
            $etag,
32 3
            $updatedAt,
33 3
            $updatedBy,
34 3
            $createdAt
35
        );
36
    }
37
38 3
    public static function new(string $name): self
39
    {
40 3
        return new self(
41 3
            Uuid::uuid1(),
42 3
            $name
43
        );
44
    }
45
46 5
    public function getUuid(): UuidInterface
47
    {
48 5
        return $this->uuid;
49
    }
50
51 3
    public function getName(): string
52
    {
53 3
        return $this->name;
54
    }
55
56 3
    public function getEtag(): ?string
57
    {
58 3
        return $this->etag;
59
    }
60
61 3
    public function getUpdatedAt(): ?DateTime
62
    {
63 3
        return $this->updatedAt;
64
    }
65
66 3
    public function getUpdatedBy(): ?UuidInterface
67
    {
68 3
        return $this->updatedBy;
69
    }
70
71 3
    public function getCreatedAt(): ?DateTime
72
    {
73 3
        return $this->createdAt;
74
    }
75
76 2
    public function getCreateData(): string
77
    {
78
        $data = [
79 2
            'uuid' => $this->uuid,
80 2
            'name' => $this->name,
81
        ];
82
83 2
        return json_encode($data);
84
    }
85
86 6
    private function __construct(
87
        UuidInterface $uuid,
88
        string $name,
89
        ?string $etag = null,
90
        ?DateTime $updatedAt = null,
91
        ?UuidInterface $updatedBy = null,
92
        ?DateTime $createdAt = null
93
    ) {
94 6
        $this->uuid = $uuid;
95 6
        $this->name = $name;
96 6
        $this->etag = $etag;
97 6
        $this->updatedAt = $updatedAt;
98 6
        $this->updatedBy = $updatedBy;
99 6
        $this->createdAt = $createdAt;
100 6
    }
101
}
102