Completed
Push — master ( 5a1ced...5e31e4 )
by Lukas Kahwe
18:21 queued 11:48
created

ExceptionWrapperHandlerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.2099
Metric Value
dl 0
loc 12
ccs 5
cts 7
cp 0.7143
rs 9.4286
cc 3
eloc 6
nc 3
nop 1
crap 3.2099
1
<?php
2
3
/*
4
 * This file is part of the FOSRestBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\RestBundle\DependencyInjection\Compiler;
13
14
use JMS\Serializer\Handler\SubscribingHandlerInterface;
15
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
18
/**
19
 * Checks if the JMS serializer is available to be able to use the ExceptionWrapperSerializeHandler.
20
 *
21
 * @author Christian Flothmann <[email protected]>
22
 */
23
class ExceptionWrapperHandlerPass implements CompilerPassInterface
24
{
25 6
    public function process(ContainerBuilder $container)
26
    {
27 6
        if (!$container->has('fos_rest.serializer.exception_wrapper_serialize_handler')) {
28 5
            return;
29
        }
30
31 1
        if (interface_exists(SubscribingHandlerInterface::class)) {
32 1
            return;
33
        }
34
35
        $container->removeDefinition('fos_rest.serializer.exception_wrapper_serialize_handler');
36
    }
37
}
38