| Total Complexity | 6 |
| Total Lines | 105 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | class CollectionIterator implements Iterator |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * |
||
| 26 | * The fieldsets over which we are iterating. |
||
| 27 | * |
||
| 28 | * @var array |
||
| 29 | * |
||
| 30 | */ |
||
| 31 | protected $fieldsets; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * |
||
| 35 | * The keys to iterate over in the fieldsets. |
||
| 36 | * |
||
| 37 | * @var array |
||
| 38 | * |
||
| 39 | */ |
||
| 40 | protected $keys; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * |
||
| 44 | * Is the current iterator position valid? |
||
| 45 | * |
||
| 46 | * @var bool |
||
| 47 | * |
||
| 48 | */ |
||
| 49 | protected $valid; |
||
| 50 | |||
| 51 | /** |
||
| 52 | * |
||
| 53 | * Constructor. |
||
| 54 | * |
||
| 55 | * @param Collection $collection The fieldsets over which to iterate. |
||
| 56 | * |
||
| 57 | */ |
||
| 58 | public function __construct(Collection $collection) |
||
| 59 | { |
||
| 60 | $this->collection = $collection; |
||
|
|
|||
| 61 | $this->keys = $this->collection->getKeys(); |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * |
||
| 66 | * Returns the value at the current iterator position. |
||
| 67 | * |
||
| 68 | * @return mixed |
||
| 69 | * |
||
| 70 | */ |
||
| 71 | #[\ReturnTypeWillChange] |
||
| 75 | } |
||
| 76 | |||
| 77 | /** |
||
| 78 | * |
||
| 79 | * Returns the current iterator position. |
||
| 80 | * |
||
| 81 | * @return mixed |
||
| 82 | * |
||
| 83 | */ |
||
| 84 | #[\ReturnTypeWillChange] |
||
| 88 | } |
||
| 89 | |||
| 90 | /** |
||
| 91 | * |
||
| 92 | * Moves the iterator to the next position. |
||
| 93 | * |
||
| 94 | * @return void |
||
| 95 | * |
||
| 96 | */ |
||
| 97 | #[\ReturnTypeWillChange] |
||
| 98 | public function next() |
||
| 99 | { |
||
| 100 | $this->valid = (next($this->keys) !== false); |
||
| 101 | } |
||
| 102 | |||
| 103 | /** |
||
| 104 | * |
||
| 105 | * Moves the iterator to the first position. |
||
| 106 | * |
||
| 107 | * @return void |
||
| 108 | * |
||
| 109 | */ |
||
| 110 | #[\ReturnTypeWillChange] |
||
| 114 | } |
||
| 115 | |||
| 116 | /** |
||
| 117 | * |
||
| 118 | * Is the current iterator position valid? |
||
| 119 | * |
||
| 120 | * @return boolean |
||
| 121 | * |
||
| 122 | */ |
||
| 123 | #[\ReturnTypeWillChange] |
||
| 129 |