ExtractorPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 18
ccs 8
cts 8
cp 1
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 16 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
/**
11
 * @internal
12 5
 */
13
final class ExtractorPass implements CompilerPassInterface
14 5
{
15
    public function process(ContainerBuilder $container): void
16 5
    {
17 4
        $extractors = array();
18
19
        foreach ($container->findTaggedServiceIds('incenteev_translation_checker.extractor') as $id => $tags) {
20
            $extractors[] = new Reference($id);
21 5
        }
22 3
23
        // If there is only one configured extractor, skip the chain one
24 3
        if (1 === count($extractors)) {
25
            $container->setAlias('incenteev_translation_checker.extractor', new Alias((string) $extractors[0], $container->getAlias('incenteev_translation_checker.extractor')->isPublic()));
26
27 2
            return;
28 2
        }
29
30
        $container->getDefinition('incenteev_translation_checker.extractor.chain')->replaceArgument(0, $extractors);
31
    }
32
}
33