| Total Complexity | 6 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 11 | abstract class AbstractEventDispatcher implements EventDispatcherInterface |
||
| 12 | { |
||
| 13 | abstract protected function getListenerProvider(): ListenerProviderInterface; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @param object|StoppableEventInterface $event |
||
| 17 | * |
||
| 18 | * @throws \Throwable |
||
| 19 | */ |
||
| 20 | public function dispatch(object $event): object |
||
| 21 | { |
||
| 22 | if ($this->isPropagationStopped($event)) { |
||
| 23 | return $event; |
||
| 24 | } |
||
| 25 | |||
| 26 | foreach ($this->getListenerProvider()->getListenersForEvent($event) as $listener) { |
||
| 27 | $listener($event); |
||
| 28 | |||
| 29 | if ($this->isPropagationStopped($event)) { |
||
| 30 | break; |
||
| 31 | 8 | } |
|
| 32 | } |
||
| 33 | 8 | ||
| 34 | 1 | return $event; |
|
| 35 | } |
||
| 36 | |||
| 37 | 7 | /** |
|
| 38 | 7 | * @param object|StoppableEventInterface $event |
|
| 39 | */ |
||
| 40 | protected function isPropagationStopped(object $event): bool |
||
| 43 | } |
||
| 44 | } |
||
| 45 |