Refactor
Try a different way of naming and grouping classes.
This commit is contained in:
parent
52c1b33711
commit
6b6b362a49
15 changed files with 111 additions and 59 deletions
33
modules/opd_presentations/src/Events.php
Normal file
33
modules/opd_presentations/src/Events.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\opd_presentations;
|
||||
|
||||
/**
|
||||
* @implements \IteratorAggregate<Event>
|
||||
*/
|
||||
readonly final class Events implements \IteratorAggregate {
|
||||
|
||||
/**
|
||||
* @param Event[] $events
|
||||
*/
|
||||
private function __construct(private array $events) {
|
||||
}
|
||||
|
||||
public function first(): Event {
|
||||
return array_values($this->events)[0];
|
||||
}
|
||||
|
||||
public function getIterator(): \Traversable {
|
||||
return new \ArrayIterator($this->events);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Event[] $events
|
||||
*/
|
||||
public static function new(array $events): self {
|
||||
return new self($events);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue