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

29 lines
525 B
PHP
Raw Normal View History

2025-06-10 20:47:23 +01:00
<?php
declare(strict_types=1);
namespace Drupal\opd_presentations\Collection;
2025-06-12 02:10:08 +01:00
use Drupal\opd_presentations\Entity\Event;
2025-06-10 20:47:23 +01:00
/**
2025-06-12 02:10:08 +01:00
* @implements \IteratorAggregate<Event>
2025-06-10 20:47:23 +01:00
*/
readonly final class EventCollection implements \IteratorAggregate {
/**
2025-06-12 02:10:08 +01:00
* @param Event[] $events
2025-06-10 20:47:23 +01:00
*/
public function __construct(private array $events) {
}
2025-06-12 02:10:08 +01:00
public function first(): Event {
2025-06-11 09:54:18 +01:00
return array_values($this->events)[0];
}
2025-06-10 20:47:23 +01:00
public function getIterator(): \Traversable {
return new \ArrayIterator($this->events);
}
}