RequestParserCompilerPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 14 3
1
<?php
2
3
/*
4
 * This file is part of the PostmanGeneratorBundle package.
5
 *
6
 * (c) Vincent Chalamon <[email protected]>
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 PostmanGeneratorBundle\DependencyInjection\CompilerPass;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Reference;
17
18
class RequestParserCompilerPass implements CompilerPassInterface
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23 1
    public function process(ContainerBuilder $container)
24
    {
25 1
        $registryDefinition = $container->getDefinition('postman.request_parser.chain');
26
27 1
        $requestParsers = [];
28 1
        foreach ($container->findTaggedServiceIds('postman.request_parser') as $serviceId => $tags) {
29 1
            $attributes = $container->getDefinition($serviceId)->getTag('postman.request_parser');
30 1
            $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
31 1
            $requestParsers[$priority][] = new Reference($serviceId);
32 1
        }
33 1
        krsort($requestParsers);
34
35 1
        $registryDefinition->replaceArgument(0, call_user_func_array('array_merge', $requestParsers));
36 1
    }
37
}
38