Refactor
This commit is contained in:
parent
c184f79f8a
commit
9308ce76a5
2 changed files with 9 additions and 5 deletions
|
@ -15,6 +15,13 @@ readonly final class Events implements \IteratorAggregate {
|
|||
private function __construct(private array $events) {
|
||||
}
|
||||
|
||||
public function filter(\Closure $callback): self {
|
||||
return new self(array_filter(
|
||||
array: $this->events,
|
||||
callback: $callback,
|
||||
));
|
||||
}
|
||||
|
||||
public function first(): Event {
|
||||
return array_values($this->events)[0];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue