Total Complexity | 5 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
21 | abstract class AggregateId |
||
22 | { |
||
23 | /** |
||
24 | * Identifier. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | private $id; |
||
29 | |||
30 | /** |
||
31 | * @noinspection PhpDocMissingThrowsInspection |
||
32 | * |
||
33 | * @return static |
||
34 | */ |
||
35 | 10 | public static function new(): self |
|
36 | { |
||
37 | /** @noinspection PhpUnhandledExceptionInspection */ |
||
38 | 10 | return new static(uuid()); |
|
39 | } |
||
40 | |||
41 | /** |
||
42 | * @param string $id |
||
43 | * |
||
44 | * @throws \ServiceBus\EventSourcing\Exceptions\InvalidAggregateIdentifier |
||
45 | */ |
||
46 | 11 | final public function __construct(string $id) |
|
54 | 10 | } |
|
55 | |||
56 | /** |
||
57 | * @return string |
||
58 | */ |
||
59 | 10 | public function toString(): string |
|
60 | { |
||
61 | 10 | return $this->id; |
|
62 | } |
||
63 | |||
64 | /** |
||
65 | * @deprecated |
||
66 | * |
||
67 | * @return string |
||
68 | */ |
||
69 | 7 | public function __toString(): string |
|
72 | } |
||
73 | } |
||
74 |