RegisterFOSServicePass::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 11
cts 11
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 1
crap 2
1
<?php
2
3
/*
4
 * This file is part of the Ivory Serializer bundle package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\SerializerBundle\DependencyInjection\Compiler;
13
14
use Ivory\SerializerBundle\FOS\Type\ExceptionType;
15
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Reference;
18
19
/**
20
 * @author GeLo <[email protected]>
21
 */
22
class RegisterFOSServicePass implements CompilerPassInterface
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27 225
    public function process(ContainerBuilder $container)
28
    {
29 225
        if (!$container->hasDefinition('fos_rest.exception.messages_map')) {
30 216
            $container->removeDefinition('ivory.serializer.fos');
31
32 216
            return;
33
        }
34
35 9
        $exceptionType = $container->getDefinition('ivory.serializer.type.exception');
36
        $exceptionType
37 9
            ->setClass(ExceptionType::class)
38 9
            ->setArguments([
39 9
                new Reference('fos_rest.exception.messages_map'),
40 9
                $exceptionType->getArgument(0),
41 7
            ]);
42 9
    }
43
}
44