| Total Complexity | 9 |
| Total Lines | 59 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class Mediator |
||
| 9 | { |
||
| 10 | /** @var ListenerInterface[][] */ |
||
| 11 | private $listeners = []; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @return ListenerInterface[][] |
||
| 15 | */ |
||
| 16 | 1 | public function getListeners(): array |
|
| 17 | { |
||
| 18 | 1 | return $this->listeners; |
|
| 19 | } |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param ListenerInterface $listener |
||
| 23 | * @return Mediator |
||
| 24 | */ |
||
| 25 | 2 | public function addListener(ListenerInterface $listener): self |
|
| 26 | { |
||
| 27 | 2 | $this->listeners[$listener->getEventName()][] = $listener; |
|
| 28 | |||
| 29 | 2 | return $this; |
|
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @param ListenerInterface $listener |
||
| 34 | * @return Mediator |
||
| 35 | */ |
||
| 36 | 2 | public function removeListener(ListenerInterface $listener): self |
|
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @param string $eventName |
||
| 57 | * @param EventInterface $event |
||
| 58 | */ |
||
| 59 | 2 | public function notify($eventName, EventInterface $event) |
|
| 67 | } |
||
| 68 | 2 | } |
|
| 71 |