SerializerCompilerPass::process()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 18
Code Lines 10

Duplication

Lines 18
Ratio 100 %

Code Coverage

Tests 13
CRAP Score 4.0058

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 18
loc 18
ccs 13
cts 14
cp 0.9286
rs 9.2
cc 4
eloc 10
nc 4
nop 1
crap 4.0058
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 View Code Duplication
class SerializerCompilerPass implements CompilerPassInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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