Conditions | 7 |
Paths | 6 |
Total Lines | 23 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 8.323 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
32 | 2 | public function dispatch(object $event) |
|
33 | { |
||
34 | // If the event is already stopped, this method becomes a no-op. |
||
35 | 2 | if ($event instanceof StoppableEventInterface && $event->isPropagationStopped()) { |
|
36 | return $event; |
||
37 | } |
||
38 | |||
39 | 2 | foreach ($this->listenerProvider->getListenersForEvent($event) as $listener) { |
|
40 | // Technically this has an extraneous stopped-check after the last listener, |
||
41 | // but that doesn't violate the spec since it's still technically checking |
||
42 | // before each listener is called, given the check above. |
||
43 | try { |
||
44 | 2 | $listener($event); |
|
45 | 2 | if ($event instanceof StoppableEventInterface && $event->isPropagationStopped()) { |
|
46 | 2 | break; |
|
47 | } |
||
48 | } catch (\Exception $e) { |
||
49 | // We do not catch Errors here, because Errors indicate the developer screwed up in |
||
50 | // some way. Let those bubble up because they should just become fatals. |
||
51 | throw $e; |
||
52 | } |
||
53 | } |
||
54 | 2 | return $event; |
|
55 | } |
||
57 |