1 | <?php |
||
17 | final class IdentityMap implements MapsObjectsByIdentity |
||
18 | { |
||
19 | private $objectWith; |
||
20 | private $entityIdFor; |
||
21 | |||
22 | private function __construct(array $objectsByClassAndId, array $idsByObject) |
||
27 | |||
28 | /** |
||
29 | * Produces a new identity map that contains the objects. |
||
30 | * |
||
31 | * @param object[] $theseObjects The objects to add, as [id => object] |
||
32 | * @return MapsObjectsByIdentity The map of objects. |
||
33 | */ |
||
34 | public static function with(array $theseObjects): MapsObjectsByIdentity |
||
44 | |||
45 | /** |
||
46 | * Produces an empty identity map. |
||
47 | * |
||
48 | * @return MapsObjectsByIdentity The empty map of objects. |
||
49 | */ |
||
50 | public static function startEmpty(): MapsObjectsByIdentity |
||
54 | |||
55 | /** @inheritdoc */ |
||
56 | public function has(string $class, string $id): bool |
||
60 | |||
61 | /** @inheritdoc */ |
||
62 | public function hasThe(object $object): bool |
||
66 | |||
67 | /** @inheritdoc */ |
||
68 | public function get(string $class, string $id): object |
||
73 | |||
74 | /** @inheritdoc */ |
||
75 | public function add(string $id, object $object): MapsObjectsByIdentity |
||
85 | |||
86 | /** @inheritdoc */ |
||
87 | public function remove(string $class, string $id): MapsObjectsByIdentity |
||
98 | |||
99 | /** @inheritdoc */ |
||
100 | public function removeThe(object $object): MapsObjectsByIdentity |
||
104 | |||
105 | /** @inheritdoc */ |
||
106 | public function removeAllObjectsOfThe(string $class): MapsObjectsByIdentity |
||
120 | |||
121 | /** @inheritdoc */ |
||
122 | public function idOf(object $object): string |
||
129 | |||
130 | /** @inheritdoc */ |
||
131 | public function classes(): array |
||
135 | |||
136 | /** @throws NoSuchObject */ |
||
137 | private function mustHave(string $class, string $id): void |
||
144 | |||
145 | /** @throws AlreadyThere */ |
||
146 | private function mayNotAlreadyHave(string $class, string $id): void |
||
152 | |||
153 | private static function addTo( |
||
161 | } |
||
162 |