| Total Complexity | 11 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 10 | class Event |
||
| 11 | { |
||
| 12 | static $events; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Register an event before it becoming available for use |
||
| 16 | */ |
||
| 17 | private static function register(string $eventname): void |
||
| 18 | { |
||
| 19 | if (!isset(self::$events[$eventname])) { |
||
| 20 | self::$events[$eventname] = array(); |
||
| 21 | } |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Subscribe to a defined event. |
||
| 26 | */ |
||
| 27 | public static function subscribeTo(string $eventname, callable $callback, int $priority = 0): void |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Trigger an event, and call all subscribers, giving an array of params. |
||
| 37 | * returns the data returned by the last subscriber. |
||
| 38 | */ |
||
| 39 | public static function dispatch($eventname, $params) : mixed |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Check that an event is valid before interacting with it. |
||
| 56 | * |
||
| 57 | */ |
||
| 58 | private static function isEvent($eventname) |
||
| 67 |