TransformerCompilerPass   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
c 3
b 0
f 0
lcom 0
cbo 3
dl 0
loc 25
ccs 11
cts 11
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 15 4
1
<?php
2
3
namespace Alchemy\RestBundle\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 TransformerCompilerPass implements CompilerPassInterface
10
{
11
    /**
12
     * You can modify the container here before it is dumped to PHP code.
13
     *
14
     * @param ContainerBuilder $container
15
     *
16
     * @api
17
     */
18 6
    public function process(ContainerBuilder $container)
19
    {
20 6
        if (! $container->hasDefinition('alchemy_rest.transformer_registry')) {
21 2
            return;
22
        }
23
24 4
        $transformerRegistry = $container->findDefinition('alchemy_rest.transformer_registry');
25 4
        $transformerTags = $container->findTaggedServiceIds('alchemy_rest.transformer');
26
27 4
        foreach ($transformerTags as $id => $tags) {
28 2
            foreach ($tags as $tag) {
29 2
                $transformerRegistry->addMethodCall('setTransformer', array($tag['alias'], new Reference($id)));
30 2
            }
31 4
        }
32 4
    }
33
}
34