| Conditions | 6 |
| Paths | 6 |
| Total Lines | 30 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 6.0702 |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | 3 | public function process(ContainerBuilder $container) |
|
| 24 | { |
||
| 25 | 3 | if (!$container->hasDefinition('strategy.factory')) { |
|
| 26 | return; |
||
| 27 | } |
||
| 28 | |||
| 29 | 3 | $definition = $container->getDefinition('strategy.factory'); |
|
| 30 | 3 | $taggedServices = $container->findTaggedServiceIds('strategy'); |
|
| 31 | |||
| 32 | 3 | foreach ($taggedServices as $id => $tagsAttributes) { |
|
| 33 | 3 | foreach ($tagsAttributes as $attributes) { |
|
| 34 | $attributes += array( |
||
| 35 | 3 | 'alias' => $id, |
|
| 36 | 'configuration' => false, |
||
| 37 | ); |
||
| 38 | |||
| 39 | 3 | if ($attributes['configuration']) { |
|
| 40 | 3 | $ref = new \ReflectionClass($attributes['configuration']); |
|
| 41 | 3 | if (!$ref->implementsInterface('Symfony\Component\Config\Definition\ConfigurationInterface')) { |
|
| 42 | throw new \Exception(sprintf('The tag attribute "configuration" for service "%s" must implement "Symfony\Component\Config\Definition\ConfigurationInterface"', $id)); |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | 3 | $definition->addMethodCall( |
|
| 47 | 3 | 'addStrategy', |
|
| 48 | 3 | array($id, $attributes['alias'], $attributes['configuration']) |
|
| 49 | ); |
||
| 50 | } |
||
| 51 | } |
||
| 52 | 3 | } |
|
| 53 | } |
||
| 54 |