vendor/symfony/form/ChoiceList/View/ChoiceGroupView.php line 21

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Form\ChoiceList\View;
  11. /**
  12. * Represents a group of choices in templates.
  13. *
  14. * @author Bernhard Schussek <bschussek@gmail.com>
  15. *
  16. * @implements \IteratorAggregate<array-key, ChoiceGroupView|ChoiceView>
  17. */
  18. class ChoiceGroupView implements \IteratorAggregate
  19. {
  20. public $label;
  21. public $choices;
  22. /**
  23. * Creates a new choice group view.
  24. *
  25. * @param array<array-key, ChoiceGroupView|ChoiceView> $choices the choice views in the group
  26. */
  27. public function __construct(string $label, array $choices = [])
  28. {
  29. $this->label = $label;
  30. $this->choices = $choices;
  31. }
  32. /**
  33. * {@inheritdoc}
  34. *
  35. * @return \Traversable<array-key, ChoiceGroupView|ChoiceView>
  36. */
  37. #[\ReturnTypeWillChange]
  38. public function getIterator()
  39. {
  40. return new \ArrayIterator($this->choices);
  41. }
  42. }