Completed
Push — master ( 57982d...fe07a0 )
by Julián
02:36
created

GenericAggregateRepository::getStoreStream()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * event-sourcing (https://github.com/phpgears/event-sourcing).
5
 * Event Sourcing base.
6
 *
7
 * @license MIT
8
 * @link https://github.com/phpgears/event-sourcing
9
 * @author Julián Gutiérrez <[email protected]>
10
 */
11
12
declare(strict_types=1);
13
14
namespace Gears\EventSourcing\Repository;
15
16
use Gears\EventSourcing\Store\Event\EventStore;
17
use Gears\EventSourcing\Store\GenericStoreStream;
18
use Gears\EventSourcing\Store\Snapshot\SnapshotStore;
19
use Gears\EventSourcing\Store\StoreStream;
20
use Gears\Identity\Identity;
21
22
/**
23
 * Abstract aggregate repository.
24
 */
25
final class GenericAggregateRepository extends AbstractAggregateRepository
26
{
27
    /**
28
     * @var string
29
     */
30
    private $aggregateRootClass;
31
32
    /**
33
     * AbstractAggregateRepository constructor.
34
     *
35
     * @param string             $aggregateRootClass
36
     * @param EventStore         $eventStore
37
     * @param SnapshotStore|null $snapshotStore
38
     */
39
    public function __construct(
40
        string $aggregateRootClass,
41
        EventStore $eventStore,
42
        ?SnapshotStore $snapshotStore = null
43
    ) {
44
        parent::__construct($eventStore, $snapshotStore);
45
46
        $this->aggregateRootClass = $aggregateRootClass;
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    protected function getStoreStream(Identity $aggregateId): StoreStream
53
    {
54
        return GenericStoreStream::fromAggregateData($this->aggregateRootClass, $aggregateId);
55
    }
56
}
57