InMemorySnapshotPersister   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 3 1
A snapshot() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Blixit\EventSourcing\Store\InMemory;
6
7
use Blixit\EventSourcing\Store\SnapshotStore\Snapshot;
8
use Blixit\EventSourcing\Store\SnapshotStore\SnapshotInterface;
9
use Blixit\EventSourcing\Store\SnapshotStore\SnapshotPersisterInterface;
10
11
class InMemorySnapshotPersister implements SnapshotPersisterInterface
12
{
13
    /** @var Snapshot[] $snapshots */
14
    private $snapshots = [];
15
16
    public function snapshot(SnapshotInterface $snapshot) : void
17
    {
18
        $this->snapshots[$snapshot->getStreamName()] = $snapshot;
19
    }
20
21
    /**
22
     * @param mixed $aggregateId
23
     */
24
    public function get(string $streamName) : ?SnapshotInterface
25
    {
26
        return $this->snapshots[$streamName] ?? null;
27
    }
28
}
29