AggregateRoot::setAggregateId()   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\Aggregate;
6
7
use Blixit\EventSourcing\Event\EventAccessor;
8
use Blixit\EventSourcing\Event\EventInterface;
9
10
abstract class AggregateRoot implements AggregateRootInterface
11
{
12
    public const DEFAULT_SEQUENCE_POSITION = 0;
13
14
    /** @var mixed $aggregateId */
15
    protected $aggregateId;
16
17
    /** @var int $versionSequence */
18
    protected $versionSequence = self::DEFAULT_SEQUENCE_POSITION; // phpcs:ignore
19
20
    /** @var EventInterface[] $recordedEvents */
21
    protected $recordedEvents = [];
22
23
    /** @var EventAccessor $eventAccessor */
24
    protected $eventAccessor;
25
26
    /**
27
     * @param mixed $aggregateId
28
     */
29
    public function setAggregateId($aggregateId) : void
30
    {
31
        $this->aggregateId = $aggregateId;
32
    }
33
34
    /**
35
     * @return mixed
36
     */
37
    public function getAggregateId()
38
    {
39
        return $this->aggregateId;
40
    }
41
42
    public function getSequence() : int
43
    {
44
        return $this->versionSequence;
45
    }
46
47
    public function record(EventInterface $event) : void
48
    {
49
        $this->recordedEvents[] = $event;
50
    }
51
52
    /**
53
     * @return EventInterface[]
54
     */
55
    public function getRecordedEvents() : array
56
    {
57
        return $this->recordedEvents;
58
    }
59
60
    public function apply(EventInterface $event) : void
61
    {
62
    }
63
}
64