Completed
Pull Request — master (#4)
by Pavel
10:02
created

ApiFactoryPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3.0123

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 8
cts 9
cp 0.8889
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 1
crap 3.0123
1
<?php
2
3
namespace Bankiru\Api\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 ApiFactoryPass implements CompilerPassInterface
10
{
11
    /** {@inheritdoc} */
12 5
    public function process(ContainerBuilder $container)
13
    {
14 5
        if (!$container->hasDefinition('bankiru_api.api_factory.chain')) {
15
            return;
16
        }
17
18 5
        $chain = $container->getDefinition('bankiru_api.api_factory.chain');
19
20 5
        $factories = $container->findTaggedServiceIds('bankiru.api_factory');
21
22 5
        foreach ($factories as $id => $tags) {
23 5
            $chain->addMethodCall('add', [new Reference($id)]);
24 5
        }
25 5
    }
26
}
27