Total Complexity | 9 |
Total Lines | 72 |
Duplicated Lines | 0 % |
Coverage | 80.95% |
Changes | 0 |
1 | <?php |
||
10 | class HandlerCollection implements \Iterator, \Countable |
||
11 | { |
||
12 | /** |
||
13 | * @var \Xervice\Logger\Business\Dependency\Handler\LogHandlerInterface[] |
||
14 | */ |
||
15 | private $collection; |
||
16 | |||
17 | /** |
||
18 | * @var int |
||
19 | */ |
||
20 | private $position; |
||
21 | |||
22 | /** |
||
23 | * Collection constructor. |
||
24 | * |
||
25 | * @param \Xervice\Logger\Business\Dependency\Handler\LogHandlerInterface[] $collection |
||
26 | */ |
||
27 | 1 | public function __construct(array $collection) |
|
28 | { |
||
29 | 1 | foreach ($collection as $validator) { |
|
30 | 1 | $this->add($validator); |
|
31 | } |
||
32 | 1 | } |
|
33 | |||
34 | /** |
||
35 | * @param \Xervice\Logger\Business\Dependency\Handler\LogHandlerInterface $validator |
||
36 | */ |
||
37 | 1 | public function add(LogHandlerInterface $validator): void |
|
38 | { |
||
39 | 1 | $this->collection[] = $validator; |
|
40 | 1 | } |
|
41 | |||
42 | /** |
||
43 | * @return \Xervice\Logger\Business\Dependency\Handler\LogHandlerInterface |
||
44 | */ |
||
45 | 1 | public function current(): LogHandlerInterface |
|
46 | { |
||
47 | 1 | return $this->collection[$this->position]; |
|
48 | } |
||
49 | |||
50 | 1 | public function next(): void |
|
51 | { |
||
52 | 1 | $this->position++; |
|
53 | 1 | } |
|
54 | |||
55 | /** |
||
56 | * @return int |
||
57 | */ |
||
58 | public function key(): int |
||
59 | { |
||
60 | return $this->position; |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @return bool |
||
65 | */ |
||
66 | 1 | public function valid(): bool |
|
67 | { |
||
68 | 1 | return isset($this->collection[$this->position]); |
|
69 | } |
||
70 | |||
71 | 1 | public function rewind(): void |
|
72 | { |
||
73 | 1 | $this->position = 0; |
|
74 | 1 | } |
|
75 | |||
76 | /** |
||
77 | * @return int |
||
78 | */ |
||
79 | public function count(): int |
||
82 | } |
||
83 | } |