| Total Complexity | 6 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 2 |
| 1 | <?php |
||
| 24 | trait HasEvents { |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Event holder |
||
| 28 | * |
||
| 29 | * @var array $events |
||
| 30 | */ |
||
| 31 | protected $events = []; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Set a specific event |
||
| 35 | * @param $section |
||
| 36 | * @param $event |
||
| 37 | * @param $class |
||
| 38 | */ |
||
| 39 | public function setEvent($section, $event, $class) { |
||
| 40 | if (isset($this->events[$section])) { |
||
| 41 | $this->events[$section][$event] = $class; |
||
| 42 | } |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Set all events |
||
| 47 | * @param $events |
||
| 48 | */ |
||
| 49 | public function setEvents($events) { |
||
| 50 | $this->events = $events; |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Get a specific event callback |
||
| 55 | * @param $section |
||
| 56 | * @param $event |
||
| 57 | * |
||
| 58 | * @return Event|string |
||
| 59 | * @throws EventNotFoundException |
||
| 60 | */ |
||
| 61 | public function getEvent($section, $event) { |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Get all events |
||
| 70 | * |
||
| 71 | * @return array |
||
| 72 | */ |
||
| 73 | public function getEvents(): array { |
||
| 77 | } |