ExecutorCompilerPass::process()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 23
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 3.0052

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 23
ccs 11
cts 12
cp 0.9167
rs 9.0856
cc 3
eloc 12
nc 3
nop 1
crap 3.0052
1
<?php
2
3
namespace Velikonja\LabbyBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
class ExecutorCompilerPass implements CompilerPassInterface
10
{
11
    /**
12
     * You can modify the container here before it is dumped to PHP code.
13
     *
14
     * @param ContainerBuilder $container
15
     *
16
     * @api
17
     */
18 2
    public function process(ContainerBuilder $container)
19
    {
20 2
        if (! $container->hasDefinition('velikonja_labby.executor.executor_runner')) {
21
            return;
22
        }
23
24 2
        $definition = $container->getDefinition(
25 2
            'velikonja_labby.executor.executor_runner'
26
        );
27
28 2
        $taggedServices = $container->findTaggedServiceIds(
29 2
            'velikonja_labby.executor'
30
        );
31
32 2
        foreach ($taggedServices as $id => $tags) {
33 2
            $definition->addMethodCall(
34 2
                'addExecutor',
35
                array(
36 2
                    new Reference($id)
37
                )
38
            );
39
        }
40 2
    }
41
}
42