* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.1
*/
-final class LabelPickerGroup implements \Countable, \Iterator
+final class LabelPickerGroup implements \Countable, \IteratorAggregate
{
/**
* @var LabelPicker[]
*/
private readonly array $positionToGroupID;
- private int $position = 0;
-
/**
* @param LabelPicker[] $labelPickers
*/
return \count($this->labelPickers);
}
- public function current(): LabelPicker
- {
- $groupID = $this->positionToGroupID[$this->position];
- return $this->labelPickers[$groupID];
- }
-
- public function key(): int
- {
- return $this->position;
- }
-
- public function next(): void
- {
- $this->position++;
- }
-
- public function rewind(): void
- {
- $this->position = 0;
- }
-
- public function valid(): bool
+ public function getIterator(): \Traversable
{
- return isset($this->positionToGroupID[$this->position]);
+ return new \ArrayIterator($this->labelPickers);
}
/**