*/ declare(strict_types=1); namespace oat\taoQtiTest\models\runner\config\Business\Domain; use IteratorAggregate; class OptionCollection implements IteratorAggregate { /** @var Option[] */ private $options; public function __construct(Option ...$options) { $this->options = $options; } /** * @return Option[] */ public function getIterator(): iterable { yield from $this->options; } public function filter(callable $callback): self { $resultingOptions = []; foreach ($this as $option) { if ($callback($option)) { $resultingOptions[] = $option; } } return new self(...$resultingOptions); } }