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

RawEventStream   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
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 19
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getIterator() 0 8 3
1
<?php
2
3
4
namespace Gica\Cqrs\EventStore\InMemory;
5
6
7
use Gica\Cqrs\EventStore\EventStream;
8
9
class RawEventStream implements EventStream
10
{
11
12
    private $eventsArray = [];
13
14 3
    public function __construct($eventsArray)
15
    {
16 3
        $this->eventsArray = $eventsArray;
17 3
    }
18
19 2
    public function getIterator()
20
    {
21 2
        if ($this->eventsArray instanceof \Iterator || $this->eventsArray instanceof \IteratorAggregate) {
22 1
            return new \ArrayIterator(iterator_to_array($this->eventsArray));
23
        }
24
25 2
        return new \ArrayIterator($this->eventsArray);
26
    }
27
}