RegisterHandlersPass::process()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 19
Code Lines 11

Duplication

Lines 9
Ratio 47.37 %

Code Coverage

Tests 11
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 9
loc 19
ccs 11
cts 11
cp 1
rs 9.2
cc 4
eloc 11
nc 4
nop 1
crap 4
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\CommandBusBundle\DependencyInjection\Compiler;
5
6
use Innmind\CommandBusBundle\Exception\LogicException;
7
use Symfony\Component\DependencyInjection\{
8
    ContainerBuilder,
9
    Compiler\CompilerPassInterface
10
};
11
12
final class RegisterHandlersPass implements CompilerPassInterface
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17 3
    public function process(ContainerBuilder $container)
18
    {
19 3
        $ids = $container->findTaggedServiceIds('innmind_command_bus.handler');
20 3
        $services = [];
21
22 3 View Code Duplication
        foreach ($ids as $id => $tags) {
23 2
            foreach ($tags as $tag => $attributes) {
24 2
                if (!isset($attributes['handles'])) {
25 1
                    throw new LogicException;
26
                }
27
28 1
                $services[$attributes['handles']] = $id;
29
            }
30
        }
31
32
        $container
33 2
            ->getDefinition('innmind_command_bus.default')
34 2
            ->replaceArgument(1, $services);
35 2
    }
36
}
37