| Total Complexity | 7 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | class ApplicationListenerProvider implements ListenerProviderInterface |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * @template T of EventListenerInterface |
||
| 23 | * |
||
| 24 | * @param iterable<class-string<T>> $eventListenersClasses |
||
| 25 | */ |
||
| 26 | 6 | public function __construct( |
|
| 27 | private readonly AutowireHelperInterface $autowireHelper, |
||
| 28 | private readonly iterable $eventListenersClasses, |
||
| 29 | ) { |
||
| 30 | 6 | } |
|
| 31 | |||
| 32 | /** |
||
| 33 | * {@inheritDoc} |
||
| 34 | */ |
||
| 35 | 3 | public function getListenersForEvent(EventInterface $event): iterable |
|
| 36 | { |
||
| 37 | 3 | foreach ($this->getEventListeners() as $listenerClass) { |
|
| 38 | 2 | if (!$listenerClass::supports($event)) { |
|
| 39 | 1 | continue; |
|
| 40 | } |
||
| 41 | |||
| 42 | 1 | $callback = $this->autowireHelper->autowire($listenerClass); |
|
| 43 | |||
| 44 | 1 | yield $callback(); |
|
| 45 | } |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * {@inheritDoc} |
||
| 50 | */ |
||
| 51 | 1 | public function __toString(): string |
|
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * {@inheritDoc} |
||
| 58 | */ |
||
| 59 | 2 | public function getName(): string |
|
| 60 | { |
||
| 61 | 2 | return 'events.listener_provider.default'; |
|
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * {@inheritDoc} |
||
| 66 | */ |
||
| 67 | 4 | public function getEventListeners(): iterable |
|
| 70 | } |
||
| 71 | } |
||
| 72 |