DomainEventStream::getIterator()   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 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/*
3
 * This file is part of the Borobudur-Event-Sourcing package.
4
 *
5
 * (c) Hexacodelabs <http://hexacodelabs.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Borobudur\EventSourcing\Domain;
12
13
use ArrayIterator;
14
15
/**
16
 * @author      Iqbal Maulana <[email protected]>
17
 * @created     8/20/15
18
 */
19
class DomainEventStream implements DomainEventStreamInterface
20
{
21
    /**
22
     * @var array
23
     */
24
    private $events = array();
25
26
    /**
27
     * Constructor.
28
     *
29
     * @param DomainMessageInterface[] $events
30
     */
31
    public function __construct(array $events)
32
    {
33
        $this->events = $events;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function all()
40
    {
41
        return $this->events;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function getIterator()
48
    {
49
        return new ArrayIterator($this->events);
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function count()
56
    {
57
        return count($this->events);
58
    }
59
}
60