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

ExceptionWrapperHandlerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 71.43%
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 15
ccs 5
cts 7
cp 0.7143
rs 10

1 Method

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