| Total Complexity | 6 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | final class MemoryStorage implements StorageInterface |
||
| 11 | { |
||
| 12 | private DebuggerIdGenerator $idGenerator; |
||
| 13 | /** |
||
| 14 | * @var CollectorInterface[] |
||
| 15 | */ |
||
| 16 | private array $collectors = []; |
||
| 17 | |||
| 18 | 24 | public function __construct(DebuggerIdGenerator $idGenerator) |
|
| 21 | 24 | } |
|
| 22 | |||
| 23 | 24 | public function addCollector(CollectorInterface $collector): void |
|
| 24 | { |
||
| 25 | 24 | $this->collectors[get_class($collector)] = $collector; |
|
| 26 | 24 | } |
|
| 27 | |||
| 28 | 8 | public function read($type = self::TYPE_INDEX): array |
|
| 29 | { |
||
| 30 | 8 | return [$this->idGenerator->getId() => $this->getData()]; |
|
| 31 | } |
||
| 32 | |||
| 33 | 24 | public function getData(): array |
|
| 34 | { |
||
| 35 | 24 | $data = []; |
|
| 36 | |||
| 37 | 24 | foreach ($this->collectors as $collector) { |
|
| 38 | 8 | $data[] = $collector->getCollected(); |
|
| 39 | } |
||
| 40 | |||
| 41 | 24 | return $data; |
|
| 42 | } |
||
| 43 | |||
| 44 | 16 | public function flush(): void |
|
| 47 | 16 | } |
|
| 48 | } |
||
| 49 |