Lines 100.00% 2 / 2
Methods 100.00% 2 / 2
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 listen 100.00% 1 / 1 100.00% 1 / 1 1
 dispatch 100.00% 1 / 1 100.00% 1 / 1 1
17class Event
18{
19    /**
20     * Register a listener for an event.
21     *
22     * @param class-string $eventClass Event class (or parent class / interface) to listen for
23     * @param callable|string $listener Callable, or class-string of an invokable listener
24     * @param int $priority Higher priorities run first; defaults to 0
25     * @return void
26     */
27    public static function listen(string $eventClass, callable|string $listener, int $priority = 0): void
28    {
29        Application::getInstance()->listen($eventClass, $listener, $priority);
30    }
31
32    /**
33     * Dispatch an event to its registered listeners.
34     *
35     * @param object $event The event to dispatch
36     * @return object The event, possibly modified by listeners
37     */
38    public static function dispatch(object $event): object
39    {
40        return Application::getInstance()->dispatch($event);
41    }
42}