AbstractEventStream::getEvents()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Domain\Eventing;
4
5
/**
6
 * @author Sebastiaan Hilbers <[email protected]>
7
 */
8
abstract class AbstractEventStream implements \IteratorAggregate, \Countable
9
{
10
    protected $identity;
11
12
    protected $events;
13
14
    public function getIterator()
15
    {
16
        return new \ArrayIterator($this->events);
17
    }
18
19
    public function getIdentity()
20
    {
21
        return $this->identity;
22
    }
23
24
    public function count()
25
    {
26
        return count($this->events);
27
    }
28
29
    public function first()
30
    {
31
        return array_shift(array_values($this->events));
0 ignored issues
show
Bug introduced by
array_values($this->events) cannot be passed to array_shift() as the parameter $array expects a reference.
Loading history...
32
    }
33
34
    public function last()
35
    {
36
        return array_pop(array_values($this->events));
0 ignored issues
show
Bug introduced by
array_values($this->events) cannot be passed to array_pop() as the parameter $array expects a reference.
Loading history...
37
    }
38
39
    public function getEvents()
40
    {
41
        return $this->events;
42
    }
43
}
44