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