| Total Complexity | 6 |
| Total Lines | 74 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class CombineIterator implements \Iterator |
||
|
|
|||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var \Iterator |
||
| 16 | */ |
||
| 17 | protected $keys; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var \Iterator |
||
| 21 | */ |
||
| 22 | protected $values; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Class constructor. |
||
| 26 | * |
||
| 27 | * @param iterable $keys |
||
| 28 | * @param iterable $values |
||
| 29 | */ |
||
| 30 | 11 | public function __construct(iterable $keys, iterable $values) |
|
| 31 | { |
||
| 32 | 11 | $this->keys = iterable_to_iterator($keys); |
|
| 33 | 11 | $this->values = iterable_to_iterator($values); |
|
| 34 | 11 | } |
|
| 35 | |||
| 36 | /** |
||
| 37 | * Get the current value. |
||
| 38 | * |
||
| 39 | * @return mixed |
||
| 40 | */ |
||
| 41 | 9 | public function current() |
|
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Get the current key. |
||
| 48 | * |
||
| 49 | * @return mixed |
||
| 50 | */ |
||
| 51 | 9 | public function key() |
|
| 52 | { |
||
| 53 | 9 | return $this->keys->current(); |
|
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Forward to the next element. |
||
| 58 | * |
||
| 59 | * @return void |
||
| 60 | */ |
||
| 61 | 9 | public function next(): void |
|
| 62 | { |
||
| 63 | 9 | $this->keys->next(); |
|
| 64 | 9 | $this->values->next(); |
|
| 65 | 9 | } |
|
| 66 | |||
| 67 | /** |
||
| 68 | * Checks if the iterator is valid. |
||
| 69 | * |
||
| 70 | * @return bool |
||
| 71 | */ |
||
| 72 | 10 | public function valid(): bool |
|
| 75 | } |
||
| 76 | |||
| 77 | /** |
||
| 78 | * Checks if the iterator is valid. |
||
| 79 | * |
||
| 80 | * @return void |
||
| 81 | */ |
||
| 82 | 10 | public function rewind(): void |
|
| 88 |