Passed
Push — master ( 7f151c...a80937 )
by Mihai
12:01
created

ServiceContainerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 8
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 6 3
1
<?php
2
3
namespace OldSound\RabbitMqBundle\DependencyInjection\Compiler;
4
5
use OldSound\RabbitMqBundle\Command\BaseRabbitMqCommand;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
class ServiceContainerPass implements CompilerPassInterface
11
{
12
    public function process(ContainerBuilder $container): void
13
    {
14
        foreach ($container->findTaggedServiceIds('console.command') as $id => $attributes) {
15
            $command = $container->findDefinition($id);
16
            if (is_a($command->getClass(), BaseRabbitMqCommand::class, true)) {
17
                $command->addMethodCall('setContainer', [new Reference('service_container')]);
18
            }
19
        }
20
    }
21
}
22