Total Complexity | 6 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
5 | class EventHandlerCollection |
||
6 | { |
||
7 | /** @var callable[][] */ |
||
8 | private $eventHandlers; |
||
9 | |||
10 | public function __construct() |
||
13 | } |
||
14 | |||
15 | /** |
||
16 | * Register an event handler. |
||
17 | * |
||
18 | * @param callable|string $event The name of the event to listen for. Pass a callable to this parameter to catch all events. |
||
19 | * @param callable|null $function The callable that will be invoked on event |
||
20 | */ |
||
21 | public function addHandler($event, ?callable $function): void |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Invoke all handlers for a specific event. |
||
37 | * |
||
38 | * @param Event $event |
||
39 | */ |
||
40 | public function invoke(Event $event): void |
||
48 |