oliverdavies.uk/modules/opd_presentations/src/Collection/EventCollection.php

28 lines
525 B
PHP

<?php
declare(strict_types=1);
namespace Drupal\opd_presentations\Collection;
use Drupal\opd_presentations\Entity\Event;
/**
* @implements \IteratorAggregate<Event>
*/
readonly final class EventCollection implements \IteratorAggregate {
/**
* @param Event[] $events
*/
public function __construct(private array $events) {
}
public function first(): Event {
return array_values($this->events)[0];
}
public function getIterator(): \Traversable {
return new \ArrayIterator($this->events);
}
}