diff --git a/EventDispatch.php b/EventDispatch.php index 77884b4..389bc54 100644 --- a/EventDispatch.php +++ b/EventDispatch.php @@ -11,6 +11,7 @@ use Psr\Container\NotFoundExceptionInterface; use Psr\EventDispatcher\EventDispatcherInterface; use Psr\EventDispatcher\StoppableEventInterface; use ReflectionException; +use SplPriorityQueue; /** @@ -23,12 +24,22 @@ class EventDispatch extends Component implements EventDispatcherInterface /** * @param object $event * @return object - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface|ReflectionException - */ + */ public function dispatch(object $event): object { $lists = make(EventProvider::class)->getListenersForEvent($event); + + return $this->execute($lists, $event); + } + + + /** + * @param SplPriorityQueue $lists + * @param object $event + * @return object + */ + public function execute(SplPriorityQueue $lists, object $event): object + { if ($lists->isEmpty()) { return $event; }