1 | <?php |
||
23 | class InMemoryEntityLookup implements EntityLookup, ItemLookup, PropertyLookup { |
||
24 | |||
25 | /** |
||
26 | * @var EntityDocument[] |
||
27 | */ |
||
28 | private $entities = []; |
||
29 | |||
30 | /** |
||
31 | * @var EntityLookupException[] |
||
32 | */ |
||
33 | private $exceptions = []; |
||
34 | |||
35 | /** |
||
36 | * @param EntityDocument ...$entities |
||
37 | */ |
||
38 | 2 | public function __construct( ...$entities ) { |
|
43 | 2 | ||
44 | 2 | /** |
|
45 | * @param EntityDocument $entity |
||
46 | * |
||
47 | * @throws InvalidArgumentException |
||
48 | */ |
||
49 | public function addEntity( EntityDocument $entity ) { |
||
56 | 2 | ||
57 | /** |
||
58 | * Registers an exception that will be thrown when a entity with the id in the exception is requested. |
||
59 | * If an exception with the same EntityId was already present it will be replaced by the new one. |
||
60 | * |
||
61 | * @since 3.1 |
||
62 | * |
||
63 | * @param EntityLookupException $exception |
||
64 | */ |
||
65 | public function addException( EntityLookupException $exception ) { |
||
68 | |||
69 | 3 | /** |
|
70 | 1 | * @see EntityLookup::getEntity |
|
71 | * |
||
72 | * @param EntityId $entityId |
||
73 | 2 | * |
|
74 | * @throws EntityLookupException |
||
75 | * @return EntityDocument |
||
76 | */ |
||
77 | public function getEntity( EntityId $entityId ) { |
||
86 | |||
87 | 3 | /** |
|
88 | * @see EntityLookup::hasEntity |
||
89 | * |
||
90 | 6 | * @param EntityId $entityId |
|
91 | 6 | * |
|
92 | 2 | * @throws EntityLookupException |
|
93 | * @return bool |
||
94 | 6 | */ |
|
95 | public function hasEntity( EntityId $entityId ) { |
||
100 | |||
101 | private function throwExceptionIfNeeded( EntityId $entityId ) { |
||
106 | |||
107 | public function getItemForId( ItemId $itemId ) { |
||
110 | |||
111 | public function getPropertyForId( PropertyId $propertyId ) { |
||
114 | |||
115 | } |
||
116 |