Total Complexity | 9 |
Total Lines | 58 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | final class MemoryStorage implements StorageInterface |
||
11 | { |
||
12 | /** |
||
13 | * @var CollectorInterface[] |
||
14 | */ |
||
15 | private array $collectors = []; |
||
16 | |||
17 | public function __construct( |
||
20 | 30 | } |
|
21 | |||
22 | public function addCollector(CollectorInterface $collector): void |
||
23 | 26 | { |
|
24 | $this->collectors[$collector->getName()] = $collector; |
||
25 | 26 | } |
|
26 | |||
27 | public function read(string $type, ?string $id = null): array |
||
28 | 8 | { |
|
29 | if ($type === self::TYPE_SUMMARY) { |
||
30 | 8 | return [ |
|
31 | 8 | $this->idGenerator->getId() => [ |
|
32 | 'id' => $this->idGenerator->getId(), |
||
33 | 'collectors' => array_keys($this->collectors), |
||
34 | 8 | ], |
|
35 | ]; |
||
36 | } |
||
37 | 24 | ||
38 | if ($type === self::TYPE_OBJECTS) { |
||
39 | 24 | return [ |
|
40 | $this->idGenerator->getId() => array_merge(...array_values($this->getData())), |
||
41 | 24 | ]; |
|
42 | 8 | } |
|
43 | |||
44 | return [$this->idGenerator->getId() => $this->getData()]; |
||
45 | 24 | } |
|
46 | |||
47 | public function getData(): array |
||
56 | } |
||
57 | |||
58 | public function flush(): void |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @codeCoverageIgnore |
||
65 | */ |
||
66 | public function clear(): void |
||
68 | } |
||
69 | } |
||
70 |