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

ErrorObservers   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 23
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 3
A getIterator() 0 4 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