for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* event (https://github.com/phpgears/event).
* Event handling.
*
* @license MIT
* @link https://github.com/phpgears/event
* @author Julián Gutiérrez <[email protected]>
*/
declare(strict_types=1);
namespace Gears\Event;
use Gears\Event\Exception\InvalidEventException;
final class EventArrayCollection implements EventCollection
{
/**
* @var Event[]
private $events = [];
* EventArrayCollection constructor.
* @param (Event|mixed)[] $events
* @throws InvalidEventException
public function __construct(array $events)
foreach ($events as $event) {
if (!$event instanceof Event) {
throw new InvalidEventException(\sprintf(
'Event collection only accepts %s, %s given',
Event::class,
\is_object($event) ? \get_class($event) : \gettype($event)
));
}
$this->events[] = $event;
* {@inheritdoc}
* @return Event
public function current(): Event
return \current($this->events);
public function next(): void
\next($this->events);
* @return string|int|null
public function key()
return \key($this->events);
public function valid(): bool
return \key($this->events) !== null;
public function rewind(): void
\reset($this->events);
public function count(): int
return \count($this->events);