GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

DoctrinePass   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 4
dl 0
loc 49
ccs 34
cts 34
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
C process() 0 46 9
1
<?php
2
3
namespace JMS\SerializerBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Alias;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
class DoctrinePass implements CompilerPassInterface
11
{
12 29
    public function process(ContainerBuilder $container)
13
    {
14 29
        if ($container->hasParameter('jms_serializer.infer_types_from_doctrine_metadata')
15 29
            && $container->getParameter('jms_serializer.infer_types_from_doctrine_metadata') === false
16 29
        ) {
17 1
            return;
18
        }
19
20
        $registries = array(
21 28
            'doctrine.orm.entity_manager' => 'doctrine',
22 28
            'doctrine_phpcr.odm.document_manager' => 'doctrine_phpcr',
23 28
        );
24
25 28
        foreach ($registries as $managerId => $registry) {
26 28
            if (!$container->has($managerId)) {
27 27
                unset($registries[$managerId]);
28 27
            }
29 28
        }
30
31 28
        if (empty($registries)) {
32 25
            return;
33
        }
34
35
        $serviceTemplates = array(
36 3
            'jms_serializer.metadata_driver' => array('template' => 'jms_serializer.metadata.%s_type_driver', 'position' => 0),
37 3
            'jms_serializer.object_constructor' => array('template' => 'jms_serializer.%s_object_constructor', 'position' => 1)
38 3
        );
39
40 3
        $registry = array_pop($registries);
41 3
        $previousId = array();
42 3
        foreach ($serviceTemplates as $serviceName => $service) {
43 3
            $previousId[$serviceName] = sprintf($service['template'], $registry);
44 3
            $container->setAlias($serviceName, new Alias($previousId[$serviceName], true));
45 3
        }
46
47 3
        foreach ($registries as $registry) {
48 1
            foreach ($serviceTemplates as $serviceName => $service) {
49 1
                $id = sprintf($service['template'], $registry);
50
                $container
51 1
                    ->findDefinition($id)
52 1
                    ->replaceArgument($service['position'], new Reference($previousId[$serviceName]));
53 1
                $previousId[$serviceName] = $id;
54 1
                $container->setAlias($serviceName, new Alias($previousId[$serviceName], true));
55 1
            }
56 3
        }
57 3
    }
58
}
59