InMemorySnapshotPersister::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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