Completed
Push — master ( 5f4179...916f6e )
by Richard
11s
created

ErrorObservers::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 1
1
<?php
2
3
namespace RMiller\BehatSpec\Extension\ErrorExtension\Observer;
4
5
class ErrorObservers implements \IteratorAggregate
6
{
7
    private $observers;
8
9
    public function __construct(array $observers = [])
10
    {
11
        foreach ($observers as $observer) {
12
            if ($observer instanceof ErrorObserver) {
13
                continue;
14
            }
15
16
            $message = 'Can only be constructed with implementations of RMiller\BehatSpec\Extension\ErrorExtension\Observer\ErrorObserver';
17
            throw new \InvalidArgumentException($message);
18
        }
19
20
        $this->observers = $observers;
21
    }
22
23
    public function getIterator()
24
    {
25
        return new \ArrayIterator($this->observers);
26
    }
27
}
28