1 | <?php |
||
21 | class InMemoryEntityLookup implements EntityLookup { |
||
22 | |||
23 | /** |
||
24 | * @var EntityDocument[] |
||
25 | */ |
||
26 | private $entities = []; |
||
27 | |||
28 | /** |
||
29 | * @var EntityLookupException[] |
||
30 | */ |
||
31 | private $exceptions = []; |
||
32 | |||
33 | /** |
||
34 | * @param EntityDocument ...$entities |
||
35 | */ |
||
36 | public function __construct( ...$entities ) { |
||
41 | |||
42 | /** |
||
43 | 2 | * @param EntityDocument $entity |
|
44 | 2 | * |
|
45 | * @throws InvalidArgumentException |
||
46 | */ |
||
47 | public function addEntity( EntityDocument $entity ) { |
||
54 | 2 | ||
55 | 2 | /** |
|
56 | 2 | * Registers an exception that will be thrown when a entity with the id in the exception is requested. |
|
57 | * If an exception with the same EntityId was already present it will be replaced by the new one. |
||
58 | * |
||
59 | * @since 3.1 |
||
60 | * |
||
61 | * @param EntityLookupException $exception |
||
62 | */ |
||
63 | public function addException( EntityLookupException $exception ) { |
||
66 | 3 | ||
67 | 3 | /** |
|
68 | * @see EntityLookup::getEntity |
||
69 | 3 | * |
|
70 | 1 | * @param EntityId $entityId |
|
71 | * |
||
72 | * @throws EntityLookupException |
||
73 | 2 | * @return EntityDocument |
|
74 | */ |
||
75 | public function getEntity( EntityId $entityId ) { |
||
84 | 3 | ||
85 | 3 | /** |
|
86 | * @see EntityLookup::hasEntity |
||
87 | 3 | * |
|
88 | * @param EntityId $entityId |
||
89 | * |
||
90 | 6 | * @throws EntityLookupException |
|
91 | 6 | * @return bool |
|
92 | 2 | */ |
|
93 | public function hasEntity( EntityId $entityId ) { |
||
98 | |||
99 | private function throwExceptionIfNeeded( EntityId $entityId ) { |
||
104 | |||
105 | } |
||
106 |