Completed
Push — master ( 8a4be1...fe7d42 )
by Constantin
06:22
created

InMemoryAggregateEventStream   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 42
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getIterator() 0 4 1
A getVersion() 0 4 1
A getSequence() 0 4 1
1
<?php
2
3
4
namespace Gica\Cqrs\EventStore\InMemory;
5
6
7
use Gica\Cqrs\EventStore\AggregateEventStream;
8
9
class InMemoryAggregateEventStream implements AggregateEventStream
10
{
11
12
    /**
13
     * @var array
14
     */
15
    private $eventsArray;
16
    private $version;
17
    private $sequence;
18
    /**
19
     * @var
20
     */
21
    private $aggregateClass;
22
    /**
23
     * @var
24
     */
25
    private $aggregateId;
26
27 5
    public function __construct(array $eventsArray, $aggregateClass, $aggregateId, int $sequence)
28
    {
29 5
        $this->version = count($eventsArray);
30 5
        $this->aggregateClass = $aggregateClass;
31 5
        $this->aggregateId = $aggregateId;
32 5
        $this->eventsArray = $eventsArray;
33 5
        $this->sequence = $sequence;
34 5
    }
35
36 5
    public function getIterator()
37
    {
38 5
        return new \ArrayIterator($this->eventsArray);
39
    }
40
41 2
    public function getVersion(): int
42
    {
43 2
        return $this->version;
44
    }
45
46 2
    public function getSequence(): int
47
    {
48 2
        return $this->sequence;
49
    }
50
}
51