1 | <?php |
||
18 | final class Whitelist implements MapsObjectsByIdentity |
||
19 | { |
||
20 | private $allow; |
||
21 | private $map; |
||
22 | |||
23 | private function __construct(array $allow, MapsObjectsByIdentity $map) |
||
28 | |||
29 | /** |
||
30 | * Constructs a whitelist for the identity map. |
||
31 | * |
||
32 | * @param MapsObjectsByIdentity $mapped The actual identity map. |
||
33 | * @param string ...$allowedClasses The whitelisted classes. |
||
34 | * @return MapsObjectsByIdentity The wrapped identity map. |
||
35 | */ |
||
36 | public static function forThe( |
||
46 | |||
47 | /** |
||
48 | * Whitelists the given classes in the identity map. |
||
49 | * |
||
50 | * @param string ...$classes The whitelisted classes. |
||
51 | * @return MapsObjectsByIdentity The wrapped identity map. |
||
52 | */ |
||
53 | public static function the(string ...$classes): MapsObjectsByIdentity |
||
57 | |||
58 | /** @inheritdoc */ |
||
59 | public function has(string $class, string $id): bool |
||
63 | |||
64 | /** @inheritdoc */ |
||
65 | public function hasThe(object $object): bool |
||
69 | |||
70 | /** @inheritdoc */ |
||
71 | public function get(string $class, string $id): object |
||
75 | |||
76 | /** @inheritdoc */ |
||
77 | public function idOf(object $object): string |
||
81 | |||
82 | /** @inheritdoc */ |
||
83 | public function add(string $id, object $object): MapsObjectsByIdentity |
||
90 | |||
91 | /** @inheritdoc */ |
||
92 | public function remove(string $class, string $id): MapsObjectsByIdentity |
||
96 | |||
97 | /** @inheritdoc */ |
||
98 | public function removeThe(object $object): MapsObjectsByIdentity |
||
102 | |||
103 | /** @inheritdoc */ |
||
104 | public function removeAllObjectsOfThe(string $class): MapsObjectsByIdentity |
||
111 | |||
112 | /** @inheritdoc */ |
||
113 | public function classes(): array |
||
117 | |||
118 | private static function purgeIfNotIn( |
||
128 | |||
129 | private function newMap(MapsObjectsByIdentity $map): MapsObjectsByIdentity |
||
133 | } |
||
134 |