Completed
Pull Request — master (#16)
by Christophe
06:47 queued 23s
created

ExtractorPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 17 3
1
<?php
2
3
namespace Incenteev\TranslationCheckerBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Alias;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
class ExtractorPass implements CompilerPassInterface
11
{
12
    public function process(ContainerBuilder $container)
13
    {
14
        $extractors = array();
15
16
        foreach ($container->findTaggedServiceIds('incenteev_translation_checker.extractor') as $id => $tags) {
17
            $extractors[] = new Reference($id);
18
        }
19
20
        // If there is only one configured extractor, skip the chain one
21
        if (1 === count($extractors)) {
22
            $container->setAlias('incenteev_translation_checker.extractor', new Alias((string) $extractors[0], $container->getAlias('incenteev_translation_checker.extractor')->isPublic()));
23
24
            return;
25
        }
26
27
        $container->getDefinition('incenteev_translation_checker.extractor.chain')->replaceArgument(0, $extractors);
28
    }
29
}
30