Refactor
This commit is contained in:
parent
c84e6ed25c
commit
8ec5b621c1
3 changed files with 35 additions and 35 deletions
|
@ -12,13 +12,6 @@ use Webmozart\Assert\Assert;
|
|||
*/
|
||||
readonly final class Events implements \IteratorAggregate {
|
||||
|
||||
/**
|
||||
* @param Event[] $events
|
||||
*/
|
||||
private function __construct(private array $events) {
|
||||
Assert::allIsInstanceOf($events, Event::class);
|
||||
}
|
||||
|
||||
public function filter(\Closure $callback): self {
|
||||
return new self(array_filter(
|
||||
array: $this->events,
|
||||
|
@ -34,11 +27,18 @@ readonly final class Events implements \IteratorAggregate {
|
|||
return new \ArrayIterator($this->events);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Event[] $events
|
||||
*/
|
||||
/**
|
||||
* @param Event[] $events
|
||||
*/
|
||||
public static function fromEvents(array $events): self {
|
||||
return new self($events);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Event[] $events
|
||||
*/
|
||||
private function __construct(private array $events) {
|
||||
Assert::allIsInstanceOf($events, Event::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue