| Conditions | 8 |
| Paths | 11 |
| Total Lines | 27 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 9.214 |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | 3 | public function process(ContainerBuilder $container) |
|
| 30 | { |
||
| 31 | 3 | if (!$container->hasDefinition('fos_elastica.elastica_to_model_transformer.collection')) { |
|
| 32 | return; |
||
| 33 | } |
||
| 34 | |||
| 35 | 3 | $transformers = []; |
|
| 36 | |||
| 37 | 3 | foreach ($container->findTaggedServiceIds('fos_elastica.elastica_to_model_transformer') as $id => $tags) { |
|
| 38 | 2 | foreach ($tags as $tag) { |
|
| 39 | 2 | if (empty($tag['index']) || empty($tag['type'])) { |
|
| 40 | throw new InvalidArgumentException('The Transformer must have both a type and an index defined.'); |
||
| 41 | } |
||
| 42 | |||
| 43 | 2 | $transformers[$tag['index']][$tag['type']] = new Reference($id); |
|
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | 3 | foreach ($transformers as $index => $indexTransformers) { |
|
| 48 | 2 | if (!$container->hasDefinition(sprintf('fos_elastica.elastica_to_model_transformer.collection.%s', $index))) { |
|
| 49 | 2 | continue; |
|
| 50 | } |
||
| 51 | |||
| 52 | $index = $container->getDefinition(sprintf('fos_elastica.elastica_to_model_transformer.collection.%s', $index)); |
||
| 53 | $index->replaceArgument(0, $indexTransformers); |
||
| 54 | } |
||
| 55 | 3 | } |
|
| 56 | } |
||
| 57 |