Completed
Push — master ( 42a15b...d491ac )
by Paweł
02:03
created

CommandHandlersCompilerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 0
cbo 2
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 15 3
1
<?php
2
3
namespace Clearcode\CommandBusConsole\Bundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
8
class CommandHandlersCompilerPass implements CompilerPassInterface
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
    public function process(ContainerBuilder $container)
14
    {
15
        $commandHandlersTags = $container->findTaggedServiceIds('command_handler');
16
        $commandCollector = $container->getDefinition('command_bus_console.command_collector');
17
18
        $commands = [];
19
20
        foreach ($commandHandlersTags as $service) {
21
            foreach ($service as $tags) {
22
                $commands[] = $tags['handles'];
23
            }
24
        }
25
26
        $commandCollector->addMethodCall('processCommandServices', [$commands]);
27
    }
28
}
29