1 | <?php |
||
25 | abstract class AggregateRootIdentifier implements Stringable, Comparable, JsonSerializable |
||
26 | { |
||
27 | |||
28 | /** |
||
29 | * @var UuidInterface |
||
30 | */ |
||
31 | protected $uuid; |
||
32 | |||
33 | /** |
||
34 | * Creates an AggregateRootIdentifier |
||
35 | * |
||
36 | * @param string|null $uuidStr |
||
37 | * |
||
38 | * @throws IdentifierCreationException when internal UUID cannot be created |
||
39 | */ |
||
40 | public function __construct(string $uuidStr = null) |
||
51 | |||
52 | /** |
||
53 | * Internal UUID |
||
54 | * |
||
55 | * @return UuidInterface |
||
56 | */ |
||
57 | public function wrappedUuid(): UuidInterface |
||
61 | |||
62 | /** |
||
63 | * Compares object for equality |
||
64 | * |
||
65 | * @param mixed $other |
||
66 | * |
||
67 | * @return bool |
||
68 | */ |
||
69 | public function equalsTo($other): bool |
||
74 | |||
75 | /** |
||
76 | * String version of UUID that will be converted to a JSON string |
||
77 | * |
||
78 | * @return string data which can be serialized by json_encode(), |
||
79 | * which is a value of any type other than a resource. |
||
80 | */ |
||
81 | public function jsonSerialize() |
||
85 | |||
86 | /** |
||
87 | * String representation of the object |
||
88 | * |
||
89 | * @return string |
||
90 | */ |
||
91 | public function __toString() |
||
95 | |||
96 | /** |
||
97 | * Creates an UUID with provided UUID string |
||
98 | * |
||
99 | * @param string $uuidStr |
||
100 | * |
||
101 | * @return UuidInterface |
||
102 | * |
||
103 | * @throws IdentifierCreationException If the provided text is not a valid UUID string |
||
104 | */ |
||
105 | protected function createFromString(string $uuidStr): UuidInterface |
||
115 | } |
||
116 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: