Completed
Push — master ( 2e0cd6...c623e8 )
by Pavel
12:31
created

SymfonySerializerCompilerPass   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 70%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 5
c 3
b 0
f 0
lcom 0
cbo 2
dl 0
loc 23
rs 10
ccs 7
cts 10
cp 0.7

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 19 5
1
<?php
2
3
namespace ScayTrase\Api\Cruds\DependencyInjection\Compiler;
4
5
use ScayTrase\Api\Cruds\Adaptors\DoctrineOrm\CircularReferenceHandler;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Definition;
9
use Symfony\Component\DependencyInjection\DefinitionDecorator;
10
use Symfony\Component\DependencyInjection\Reference;
11
use Symfony\Component\Serializer\SerializerInterface;
12
13
final class SymfonySerializerCompilerPass implements CompilerPassInterface
14
{
15
    /** {@inheritdoc} */
16 2
    public function process(ContainerBuilder $container)
17
    {
18 2
        if (!$container->has('serializer') || $container->hasAlias('serializer')) {
19
20 1
            return;
21
        }
22
23 1
        $class = $container->getDefinition('serializer')->getClass();
24
25 1
        if ('%serializer.class%' === $class) {
26
            // 2.x Definition
27
            $class = $container->getParameter($class);
28
        }
29
30 1
        if (!in_array(SerializerInterface::class, class_implements($class), true)) {
31
32
            return;
33
        }
34 1
    }
35
}
36