| Conditions | 4 |
| Paths | 3 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | public function createService(ServiceLocatorInterface $serviceLocator) |
||
| 25 | { |
||
| 26 | $dispatcher = new Dispatcher(); |
||
| 27 | |||
| 28 | $config = $serviceLocator->get('Config'); |
||
| 29 | $collectorName = $config['phpab']['analytics_collector']; |
||
| 30 | |||
| 31 | if ($collectorName && $serviceLocator->has($collectorName)) { |
||
| 32 | $dataCollector = $serviceLocator->get($collectorName); |
||
| 33 | |||
| 34 | if (!$dataCollector instanceof SubscriberInterface) { |
||
| 35 | throw new RuntimeException(sprintf( |
||
| 36 | 'The data collector is not an instance of %s', |
||
| 37 | SubscriberInterface::class |
||
| 38 | )); |
||
| 39 | } |
||
| 40 | |||
| 41 | $dispatcher->addSubscriber($dataCollector); |
||
| 42 | } |
||
| 43 | |||
| 44 | return $dispatcher; |
||
| 45 | } |
||
| 46 | } |
||
| 47 |