Total Complexity | 7 |
Total Lines | 83 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | class RangeIterator implements \Iterator |
||
19 | { |
||
20 | /** |
||
21 | * @var Range $range local reference to the range to iterate |
||
22 | */ |
||
23 | protected $range; |
||
24 | |||
25 | /** |
||
26 | * @var int $index internal pointer in the range |
||
27 | */ |
||
28 | protected $index; |
||
29 | |||
30 | /** |
||
31 | * Créates the iterator |
||
32 | * |
||
33 | * Initialize internal pointer to the first position of the Range |
||
34 | * |
||
35 | * @param Range $range |
||
36 | */ |
||
37 | 1 | public function __construct(Range $range) |
|
38 | { |
||
39 | 1 | $this->range = $range; |
|
40 | 1 | $this->rewind(); |
|
41 | 1 | } |
|
42 | |||
43 | /** |
||
44 | * Return an Address representing the current element of the Range |
||
45 | * |
||
46 | * Use the ArrayAccess interface of the Range. |
||
47 | * |
||
48 | * @return \mracine\IPTools\IPv4\Address |
||
49 | */ |
||
50 | 1 | public function current() |
|
53 | } |
||
54 | |||
55 | /** |
||
56 | * Return the key of the current element |
||
57 | * |
||
58 | * @return int |
||
59 | */ |
||
60 | 1 | public function key() |
|
61 | { |
||
62 | 1 | return $this->index; |
|
63 | } |
||
64 | |||
65 | /** |
||
66 | * Move the internal pointer to the next element |
||
67 | * |
||
68 | * @return void |
||
69 | */ |
||
70 | 1 | public function next() |
|
73 | 1 | } |
|
74 | |||
75 | /** |
||
76 | * Move the internal pointer to the first element |
||
77 | * |
||
78 | * @return void |
||
79 | */ |
||
80 | 1 | public function rewind() |
|
83 | 1 | } |
|
84 | |||
85 | /** |
||
86 | * Tells if the internal pointer designs a valid element |
||
87 | * |
||
88 | * @return bool |
||
89 | */ |
||
90 | 1 | public function valid() |
|
101 | } |
||
102 | } |
||
103 | |||
105 |