TacticianMiddlewareCompilerPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 18
ccs 6
cts 7
cp 0.8571
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 12 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lamoda\TacticianQueueBundle\DependencyInjection\CompilerPass;
6
7
use Lamoda\TacticianQueue\Middleware\QueueProducerStrategy\ChainedStrategy;
8
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\DependencyInjection\Reference;
11
12
final class TacticianMiddlewareCompilerPass implements CompilerPassInterface
13
{
14
    private const QUEUE_PRODUCER_CHAIN_STRATEGY = ChainedStrategy::class;
15
    private const TACTICIAN_MIDDLEWARE_STRATEGY_TAG = 'tactician_queue.job_producing_strategy';
16
17 1
    public function process(ContainerBuilder $container)
18
    {
19 1
        if (!$container->hasDefinition(static::QUEUE_PRODUCER_CHAIN_STRATEGY)) {
20
            return;
21
        }
22
23 1
        $chainDefinition = $container->getDefinition(static::QUEUE_PRODUCER_CHAIN_STRATEGY);
24
25 1
        foreach ($container->findTaggedServiceIds(self::TACTICIAN_MIDDLEWARE_STRATEGY_TAG) as $serviceId => $tags) {
26 1
            $chainDefinition->addMethodCall('addStrategy', [new Reference($serviceId)]);
27
        }
28 1
    }
29
}
30