1 | <?php |
||
7 | trait EventTrait { |
||
8 | /** |
||
9 | * On event fired |
||
10 | * @param string $event |
||
11 | * @param callable $callback [description] |
||
12 | * @return void |
||
13 | */ |
||
14 | abstract function on($event, callable $callback); |
||
15 | |||
16 | /** |
||
17 | * Emit event |
||
18 | * @param string $event |
||
19 | * @param array $arguments |
||
20 | * @return void |
||
21 | */ |
||
22 | abstract function emit($event, array $arguments = []); |
||
23 | |||
24 | /** |
||
25 | * Helper to listing to after event |
||
26 | * |
||
27 | * @param Callable $callback |
||
28 | * @return Void |
||
29 | */ |
||
30 | public function after($callback) |
||
44 | } |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.