RegisterFOSServicePass   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 22
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 16 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