<?php
 namespace Eluceo\iCal\Domain\Collection; use ArrayIterator; use Eluceo\iCal\Domain\Entity\Event; use Iterator; final class EventsArray extends Events { private array $events = []; public function __construct(array $events) { array_walk($events, [$this, 'addEvent']); } public function getIterator(): Iterator { return new ArrayIterator($this->events); } public function addEvent(Event $event): void { $this->events[] = $event; } } 