RegisterReceiverFactoryPass   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
c 2
b 0
f 0
dl 0
loc 15
ccs 6
cts 6
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 8 2
1
<?php
2
3
namespace Bdf\QueueBundle\DependencyInjection\Compiler;
4
5
use Bdf\Queue\Consumer\Receiver\Builder\ReceiverFactory;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Reference;
9
use Symfony\Component\ExpressionLanguage\Expression;
10
11
/**
12
 * Register all the objects provide a factory for receivers.
13
 */
14
final class RegisterReceiverFactoryPass implements CompilerPassInterface
15
{
16
    public const CONFIGURATOR_TAG_NAME = 'bdf_queue.receiver_factory';
17
18
    /**
19
     * {@inheritdoc}
20
     */
21 7
    public function process(ContainerBuilder $container)
22
    {
23 7
        $factory = $container->getDefinition(ReceiverFactory::class);
24
25 7
        foreach ($container->findTaggedServiceIds(self::CONFIGURATOR_TAG_NAME) as $serviceId => $tag) {
26 7
            $factory->addMethodCall('addFactory', [
27 7
                new Expression("service('".addslashes($serviceId)."').getReceiverNames()"),
28 7
                [new Reference($serviceId), 'create'],
29 7
            ]);
30
        }
31
    }
32
}
33