| Total Complexity | 4 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | final class InMemorySnapshotStore extends AbstractSnapshotStore |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * Serialized aggregate root. |
||
| 25 | * |
||
| 26 | * @var string[] |
||
| 27 | */ |
||
| 28 | private $streams = []; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * {@inheritdoc} |
||
| 32 | */ |
||
| 33 | public function load(StoreStream $stream): ?Snapshot |
||
| 34 | { |
||
| 35 | $streamId = $this->getStreamId($stream); |
||
| 36 | if (!isset($this->streams[$streamId])) { |
||
| 37 | return null; |
||
| 38 | } |
||
| 39 | |||
| 40 | return GenericSnapshot::fromAggregateRoot($this->deserializeAggregateRoot($this->streams[$streamId])); |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * {@inheritdoc} |
||
| 45 | */ |
||
| 46 | public function store(Snapshot $snapshot): void |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Get stream identifier. |
||
| 55 | * |
||
| 56 | * @param StoreStream $stream |
||
| 57 | * |
||
| 58 | * @return string |
||
| 59 | */ |
||
| 60 | private function getStreamId(StoreStream $stream): string |
||
| 65 |