| Conditions | 6 |
| Paths | 16 |
| Total Lines | 29 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 22 | private function getEventDispatcher( |
||
| 23 | ServiceLocatorInterface $container, |
||
| 24 | $eventDispatcher, |
||
| 25 | string $serviceName |
||
| 26 | ): EventDispatcherInterface { |
||
| 27 | if (null === $eventDispatcher) { |
||
| 28 | $eventDispatcher = []; |
||
| 29 | } |
||
| 30 | |||
| 31 | if (is_array($eventDispatcher)) { |
||
| 32 | $eventDispatcher = $container->build(EventDispatcherInterface::class, $eventDispatcher); |
||
| 33 | } |
||
| 34 | |||
| 35 | if (is_string($eventDispatcher)) { |
||
| 36 | $eventDispatcher = $container->get($eventDispatcher); |
||
| 37 | } |
||
| 38 | |||
| 39 | if (!$eventDispatcher instanceof EventDispatcherInterface) { |
||
| 40 | throw new ServiceNotCreatedException( |
||
| 41 | sprintf( |
||
| 42 | 'The event dispatcher must be an object of type \'%s\'; \'%s\' provided for service \'%s\'', |
||
| 43 | EventDispatcherInterface::class, |
||
| 44 | is_object($eventDispatcher) ? get_class($eventDispatcher) : gettype($eventDispatcher), |
||
| 45 | $serviceName |
||
| 46 | ) |
||
| 47 | ); |
||
| 48 | } |
||
| 49 | |||
| 50 | return $eventDispatcher; |
||
| 51 | } |
||
| 53 |