RegisterFlushersPass   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 4
dl 0
loc 30
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 24 5
1
<?php
2
3
namespace TreeHouse\QueueBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\DefinitionDecorator;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
class RegisterFlushersPass implements CompilerPassInterface
11
{
12
    /**
13
     * @inheritdoc
14
     */
15 4
    public function process(ContainerBuilder $container)
16
    {
17 4
        if (!$container->hasDefinition('tree_house.queue.event_listener.flush')) {
18 1
            return;
19
        }
20
21 3
        $listener = $container->getDefinition('tree_house.queue.event_listener.flush');
22
23 3
        foreach (['doctrine', 'doctrine_mongodb'] as $id) {
24 3
            if ($container->hasDefinition($id)) {
25 2
                $flusherId = sprintf('tree_house.queue.flusher.%s', $id);
26
27 2
                $definition = new DefinitionDecorator('tree_house.queue.flusher.doctrine_abstract');
28 2
                $definition->addArgument(new Reference($id));
29 2
                $container->setDefinition($flusherId, $definition);
30
31 3
                $listener->addMethodCall('addFlusher', [new Reference($flusherId)]);
32
            }
33
        }
34
35 3
        foreach ($container->findTaggedServiceIds('tree_house.queue.flusher') as $id => list($tag)) {
36 1
            $listener->addMethodCall('addFlusher', [new Reference($id)]);
37
        }
38 3
    }
39
}
40