| Total Complexity | 6 |
| Total Lines | 87 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | class Iterator implements \Iterator |
||
| 25 | { |
||
| 26 | /** |
||
| 27 | * @var integer Index |
||
| 28 | * |
||
| 29 | * @since 1.0.0 |
||
| 30 | */ |
||
| 31 | private $index; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @var BitArray bits |
||
| 35 | * |
||
| 36 | * @since 1.0.0 |
||
| 37 | */ |
||
| 38 | private $bits; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Constructor |
||
| 42 | * |
||
| 43 | * @param BitArray $bits BitArray |
||
| 44 | * |
||
| 45 | * @since 1.0.0 |
||
| 46 | */ |
||
| 47 | public function __construct(BitArray $bits) |
||
| 48 | { |
||
| 49 | $this->bits = $bits; |
||
| 50 | $this->rewind(); |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Rewind the Iterator to the first element |
||
| 55 | * |
||
| 56 | * @return void |
||
| 57 | * |
||
| 58 | * @since 1.0.0 |
||
| 59 | */ |
||
| 60 | public function rewind(): void |
||
| 61 | { |
||
| 62 | $this->index = 0; |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Return the current key |
||
| 67 | * |
||
| 68 | * @return mixed The current key |
||
| 69 | * |
||
| 70 | * @since 1.0.0 |
||
| 71 | */ |
||
| 72 | public function key(): mixed |
||
| 75 | } |
||
| 76 | |||
| 77 | /** |
||
| 78 | * Return the current value |
||
| 79 | * |
||
| 80 | * @return mixed The current value |
||
| 81 | * |
||
| 82 | * @since 1.0.0 |
||
| 83 | */ |
||
| 84 | public function current(): mixed |
||
| 87 | } |
||
| 88 | |||
| 89 | /** |
||
| 90 | * Move forward to the next element |
||
| 91 | * |
||
| 92 | * @return void |
||
| 93 | * |
||
| 94 | * @since 1.0.0 |
||
| 95 | */ |
||
| 96 | public function next(): void |
||
| 97 | { |
||
| 98 | $this->index++; |
||
| 99 | } |
||
| 100 | |||
| 101 | /** |
||
| 102 | * Checks if current position is valid |
||
| 103 | * |
||
| 104 | * @return boolean |
||
| 105 | * |
||
| 106 | * @since 1.0.0 |
||
| 107 | */ |
||
| 108 | public function valid(): bool |
||
| 111 | } |
||
| 112 | } |
||
| 113 |