Total Complexity | 7 |
Total Lines | 69 |
Duplicated Lines | 0 % |
Coverage | 80% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | class AnyIterator extends GenericIterator |
||
9 | { |
||
10 | |||
11 | /** |
||
12 | * Row Elements |
||
13 | * @var array |
||
14 | */ |
||
15 | private $list; |
||
16 | |||
17 | /** |
||
18 | * Current row number |
||
19 | * @var int |
||
20 | */ |
||
21 | private $curRow; //int |
||
22 | |||
23 | /** |
||
24 | * Iterator constructor |
||
25 | * |
||
26 | * @param Row[] $list |
||
27 | */ |
||
28 | 17 | public function __construct($list) |
|
29 | { |
||
30 | 17 | $this->curRow = 0; |
|
31 | 17 | $this->list = $list; |
|
32 | } |
||
33 | |||
34 | /** |
||
35 | * How many elements have |
||
36 | * @return int |
||
37 | */ |
||
38 | 17 | public function count() |
|
39 | { |
||
40 | 17 | return count($this->list); |
|
41 | } |
||
42 | |||
43 | /** |
||
44 | * Ask the Iterator is exists more rows. Use before moveNext method. |
||
45 | * @return bool True if exist more rows, otherwise false |
||
46 | */ |
||
47 | 16 | public function hasNext() |
|
48 | { |
||
49 | 16 | return ($this->curRow < $this->count()); |
|
50 | } |
||
51 | |||
52 | /** |
||
53 | * Return the next row. |
||
54 | * |
||
55 | * @return Row|null |
||
56 | */ |
||
57 | 16 | public function moveNext() |
|
58 | { |
||
59 | 16 | if (!$this->hasNext()) { |
|
60 | return null; |
||
61 | } |
||
62 | 16 | return $this->list[$this->curRow++]; |
|
63 | } |
||
64 | |||
65 | public function key() |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @param IteratorFilter $filter |
||
72 | * @return AnyIterator |
||
73 | */ |
||
74 | 1 | public function withFilter(IteratorFilter $filter) |
|
77 | } |
||
78 | } |
||
79 |