| Total Complexity | 6 |
| Total Lines | 77 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | final class ReadOnlyIterator implements Iterator |
||
| 23 | { |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Properties |
||
| 27 | */ |
||
| 28 | |||
| 29 | /** |
||
| 30 | * The underlying decorated iterator. |
||
| 31 | * |
||
| 32 | * @var Iterator |
||
| 33 | */ |
||
| 34 | private $decorated; |
||
| 35 | |||
| 36 | |||
| 37 | /** |
||
| 38 | * Methods |
||
| 39 | */ |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Constructor |
||
| 43 | * |
||
| 44 | * @param Iterator $decorated The iterator to decorate as read-only. |
||
| 45 | */ |
||
| 46 | 36 | public function __construct(Iterator $decorated) |
|
| 47 | { |
||
| 48 | 36 | $this->decorated = $decorated; |
|
| 49 | 36 | } |
|
| 50 | |||
| 51 | /** |
||
| 52 | * Return the current element. |
||
| 53 | * |
||
| 54 | * @return mixed The current element. |
||
| 55 | */ |
||
| 56 | 36 | public function current() |
|
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Return the key of the current element. |
||
| 63 | * |
||
| 64 | * @return scalar The key of the current element. |
||
| 65 | */ |
||
| 66 | 33 | public function key() |
|
| 67 | { |
||
| 68 | 33 | return $this->decorated->key(); |
|
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Move forward to next element. |
||
| 73 | * |
||
| 74 | * @return void |
||
| 75 | */ |
||
| 76 | 36 | public function next() |
|
| 79 | 36 | } |
|
| 80 | |||
| 81 | /** |
||
| 82 | * Rewind the Iterator to the first element. |
||
| 83 | * |
||
| 84 | * @return void |
||
| 85 | */ |
||
| 86 | 36 | public function rewind() |
|
| 87 | { |
||
| 88 | 36 | $this->decorated->rewind(); |
|
| 89 | 36 | } |
|
| 90 | |||
| 91 | /** |
||
| 92 | * Checks if current position is valid. |
||
| 93 | * |
||
| 94 | * @return bool True if the current position is valid, false otherwise. |
||
| 95 | */ |
||
| 96 | 36 | public function valid(): bool |
|
| 99 | } |
||
| 100 | } |
||
| 101 |