BusPass::process()   A
last analyzed

Complexity

Conditions 5
Paths 7

Size

Total Lines 20
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 12
nc 7
nop 1
dl 0
loc 20
rs 9.5555
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Infrastructure\Common;
6
7
use App\Infrastructure\Common\CommandHandler\CommandBus;
8
use App\Infrastructure\Common\QueryHandler\QueryBus;
9
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Depend...r\CompilerPassInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Symfony\Component\DependencyInjection\ContainerBuilder;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Depend...ection\ContainerBuilder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Symfony\Component\DependencyInjection\Reference;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\DependencyInjection\Reference was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
13
class BusPass implements CompilerPassInterface
14
{
15
    public function process(ContainerBuilder $container)
16
    {
17
        if (!$container->has(CommandBus::class)) {
18
            return;
19
        }
20
        $definition = $container->findDefinition(CommandBus::class);
21
        $taggedServices = $container->findTaggedServiceIds('app.command_handler');
22
23
        foreach ($taggedServices as $id => $tags) {
24
            $definition->addMethodCall('addCommandHandler', [new Reference($id)]);
25
        }
26
27
        if (!$container->has(QueryBus::class)) {
28
            return;
29
        }
30
        $definition = $container->findDefinition(QueryBus::class);
31
        $taggedServices = $container->findTaggedServiceIds('app.query_handler');
32
33
        foreach ($taggedServices as $id => $tags) {
34
            $definition->addMethodCall('addQueryHandler', [new Reference($id)]);
35
        }
36
    }
37
}
38