Completed
Push — master ( 637e73...30874d )
by Pablo
03:20
created

QueryBusCompilerPass::process()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 8

Duplication

Lines 15
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 15
loc 15
rs 9.2
cc 4
eloc 8
nc 4
nop 1
1
<?php
2
3
namespace PhpGitHooks\Infrastructure\CommandBus\QueryBus;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
8 View Code Duplication
class QueryBusCompilerPass implements CompilerPassInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * You can modify the container here before it is dumped to PHP code.
12
     *
13
     * @param ContainerBuilder $container
14
     */
15
    public function process(ContainerBuilder $container)
16
    {
17
        if (!$container->has('query.bus')) {
18
            return;
19
        }
20
21
        $queryBus = $container->findDefinition('bus.options.resolver');
22
        $queryHandlers = $container->findTaggedServiceIds('query_handler');
23
24
        foreach ($queryHandlers as $id => $tags) {
25
            foreach ($tags as $attributes) {
26
                $queryBus->addMethodCall('addOption', [$attributes['handles'], $id]);
27
            }
28
        }
29
    }
30
}
31