ThrusterActionsBundle   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%
Metric Value
wmc 4
dl 0
loc 33
ccs 4
cts 4
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hp$0 ➔ process() 0 14 2
B build() 0 27 2
1
<?php
2
3
namespace Thruster\Bundle\ActionsBundle;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Definition;
8
use Symfony\Component\DependencyInjection\Reference;
9
use Symfony\Component\HttpKernel\Bundle\Bundle;
10
11
/**
12
 * Class ThrusterActionsBundle
13
 *
14
 * @package Thruster\Bundle\ActionsBundle
15
 * @author  Aurimas Niekis <[email protected]>
16
 */
17
class ThrusterActionsBundle extends Bundle
18
{
19
    /**
20
     * @inheritDoc
21
     */
22 1
    public function build(ContainerBuilder $container)
23
    {
24 1
        parent::build($container);
25
26 1
        $container->addCompilerPass(
27
            new class implements CompilerPassInterface
28
            {
29
                /**
30
                 * @inheritDoc
31
                 */
32
                public function process(ContainerBuilder $container)
33
                {
34
                    $executorId         = 'thruster_actions.executor';
35
                    $executorDefinition = new Definition('Thruster\Component\Actions\Executor');
36
37
                    $container->setDefinition($executorId, $executorDefinition);
38
39
                    foreach ($container->findTaggedServiceIds('thruster_action_executor') as $id => $tags) {
40
                        $definition = $container->getDefinition($id);
41
                        $name       = call_user_func([$definition->getClass(), 'getSupportedAction']);
42
43
                        $executorDefinition->addMethodCall('addExecutor', [$name, new Reference($id)]);
44
                    }
45
                }
46
            }
47
        );
48 1
    }
49
}
50