SubscriptionStrategyCompilerPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 9
c 2
b 0
f 1
dl 0
loc 20
ccs 0
cts 11
cp 0
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 15 3
1
<?php
2
3
namespace Terox\SubscriptionBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
class SubscriptionStrategyCompilerPass implements CompilerPassInterface
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function process(ContainerBuilder $container)
15
    {
16
        $factory            = $container->findDefinition('terox.subscription.registry');
17
        $strategyServiceIds = array_keys($container->findTaggedServiceIds('subscription.strategy'));
18
19
        // Add subscription strategies to factory instance
20
        foreach ($strategyServiceIds as $strategyServiceId) {
21
            $strategy = $container->findDefinition($strategyServiceId);
22
            $tag      = $strategy->getTag('subscription.strategy');
23
24
            if ('subscription' !== $tag[0]['type']) {
25
                continue;
26
            }
27
28
            $factory->addMethodCall('addStrategy', [new Reference($strategyServiceId), $tag[0]['strategy']]);
29
        }
30
    }
31
}
32