Completed
Pull Request — master (#12)
by Asmir
06:26 queued 05:05
created

AddExtensionsPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3.0067

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 10
cts 11
cp 0.9091
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 3
nop 1
crap 3.0067
1
<?php
2
3
namespace Goetas\TwitalBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
/**
10
 *
11
 * @author Asmir Mustafic <[email protected]>
12
 *
13
 */
14
class AddExtensionsPass implements CompilerPassInterface
15
{
16
17 1
    public function process(ContainerBuilder $container)
18
    {
19 1
        if (false === $container->hasDefinition('twital')) {
20
            return;
21
        }
22
23 1
        $twitalDefinition = $container->getDefinition("twital");
24 1
        $extensionsIds = $container->findTaggedServiceIds("twital.extension");
25 1
        foreach ($extensionsIds as $extensionId => $params) {
26 1
            $twitalDefinition->addMethodCall('addExtension', array(
27 1
                new Reference($extensionId)
28 1
            ));
29 1
        }
30 1
    }
31
}
32