RegisterHandlersPass   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 36 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 0
cbo 3
dl 9
loc 25
ccs 11
cts 11
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 9 19 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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