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