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

RawEventStream::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
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
}