0 follower

Final Class Yiisoft\Test\Support\EventDispatcher\SimpleEventDispatcher

InheritanceYiisoft\Test\Support\EventDispatcher\SimpleEventDispatcher
ImplementsPsr\EventDispatcher\EventDispatcherInterface

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( Closure $listeners )
$listeners Closure

Functions that will handle each event.

                public function __construct(Closure ...$listeners)
{
    $this->listeners = $listeners;
}

            
clearEvents() public method

public void clearEvents ( )

                public function clearEvents(): void
{
    $this->events = [];
}

            
dispatch() public method

public object dispatch ( object $event )
$event object

                public function dispatch(object $event): object
{
    $this->events[] = $event;
    foreach ($this->listeners as $listener) {
        if ($event instanceof StoppableEventInterface && $event->isPropagationStopped()) {
            return $event;
        }
        $listener($event);
    }
    return $event;
}

            
getEventClasses() public method

public array getEventClasses ( )

                public function getEventClasses(): array
{
    return array_map('\get_class', $this->events);
}

            
getEvents() public method

public object[] getEvents ( )

                public function getEvents(): array
{
    return $this->events;
}

            
isClassTriggered() public method

public boolean isClassTriggered ( string $class, integer|null $times null )
$class string
$times integer|null

                public function isClassTriggered(string $class, ?int $times = null): bool
{
    return $this->processBoolResult(static fn (object $event): bool => $event::class === $class, $times);
}

            
isInstanceOfTriggered() public method

public boolean isInstanceOfTriggered ( string $class, integer|null $times null )
$class string
$times integer|null

                public function isInstanceOfTriggered(string $class, ?int $times = null): bool
{
    return $this->processBoolResult(static fn (object $event): bool => $event instanceof $class, $times);
}

            
isObjectTriggered() public method

public boolean isObjectTriggered ( object $event, integer|null $times null )
$event object
$times integer|null

                public function isObjectTriggered(object $event, ?int $times = null): bool
{
    return $this->processBoolResult(static fn (object $e): bool => $e === $event, $times);
}