AggregateRoot   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 52
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getRecordedEvents() 0 3 1
A getAggregateId() 0 3 1
A record() 0 3 1
A apply() 0 2 1
A getSequence() 0 3 1
A setAggregateId() 0 3 1
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