Total Complexity | 9 |
Total Lines | 49 |
Duplicated Lines | 0 % |
Coverage | 95.65% |
Changes | 0 |
1 | <?php |
||
8 | class ObjectStorage implements ObjectStorageInterface |
||
9 | { |
||
10 | use MetadataTrait; |
||
11 | |||
12 | private $storage = []; |
||
13 | |||
14 | 13 | public function __construct(MetadataFactoryInterface $metadataFactory) |
|
17 | 13 | } |
|
18 | |||
19 | 8 | public function contains($object): bool |
|
22 | } |
||
23 | |||
24 | 8 | public function attach($object) |
|
25 | { |
||
26 | 8 | $className = get_class($object); |
|
27 | 8 | $id = $this->getIdValue($object); |
|
28 | |||
29 | 8 | if (!$id) { |
|
30 | throw new InvalidArgumentException('object has no id value'); |
||
31 | } |
||
32 | |||
33 | 8 | $this->storage[$className][$id] = $object; |
|
34 | 8 | } |
|
35 | |||
36 | 5 | public function detach($object) |
|
39 | 5 | } |
|
40 | |||
41 | 6 | public function getIterator() |
|
42 | { |
||
43 | 6 | $items = []; |
|
44 | |||
45 | 6 | foreach ($this->storage as $transferData) { |
|
46 | 5 | foreach ($transferData as $item) { |
|
47 | 5 | $items[] = $item; |
|
48 | } |
||
49 | } |
||
50 | |||
51 | 6 | return new \ArrayIterator($items); |
|
52 | } |
||
53 | |||
54 | 4 | public function isEquals($object): bool |
|
57 | } |
||
58 | } |
||
59 |