Completed
Push — master ( d8d25b...3f99c9 )
by Quentin
59s
created

SerializerCompilerPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 92.86%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
lcom 0
cbo 3
dl 0
loc 21
ccs 13
cts 14
cp 0.9286
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 18 4
1
<?php
2
3
namespace Majora\Bundle\FrameworkExtraBundle\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
 * Compiler pass to guess all serializer formats.
11
 */
12
class SerializerCompilerPass implements CompilerPassInterface
13
{
14 2
    public function process(ContainerBuilder $container)
15
    {
16 2
        if (!$container->hasDefinition('majora.serializer')) {
17
            return;
18
        }
19
20 2
        $serializer  = $container->getDefinition('majora.serializer');
21 2
        $handlersDef = $container->findTaggedServiceIds('majora.serialization_handler');
22
23 2
        foreach ($handlersDef as $id => $attributes) {
24 2
            foreach ($attributes as $attribute) {
25 2
                $serializer->addMethodCall('registerFormatHandler', array(
26 2
                    $attribute['format'],
27 2
                    new Reference($id)
28 1
                ));
29 1
            }
30 1
        }
31 2
    }
32
}
33