ProcessorsCompilerPass   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 3
dl 0
loc 30
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 24 6
1
<?php
2
/*
3
 * This file is part of the Exchange Rate Bundle, an RunOpenCode project.
4
 *
5
 * (c) 2017 RunOpenCode
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace RunOpenCode\Bundle\ExchangeRate\DependencyInjection\CompilerPass;
11
12
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
13
use Symfony\Component\DependencyInjection\ContainerBuilder;
14
use Symfony\Component\DependencyInjection\Reference;
15
16
/**
17
 * Class ProcessorsCompilerPass
18
 *
19
 * Compiler pass for processors.
20
 *
21
 * @package RunOpenCode\Bundle\ExchangeRate\DependencyInjection\CompilerPass
22
 */
23
class ProcessorsCompilerPass implements CompilerPassInterface
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28 2
    public function process(ContainerBuilder $container)
29
    {
30 2
        if ($container->has('runopencode.exchange_rate.registry.processors')) {
31
32 1
            $definition = $container->findDefinition('runopencode.exchange_rate.registry.processors');
33
34 1
            $processors = array();
35
36 1
            foreach ($container->findTaggedServiceIds('runopencode.exchange_rate.processor') as $id => $tags) {
37
38 1
                foreach ($tags as $attributes) {
39 1
                    $processors[$id] = !empty($attributes['priority']) ? (int)$attributes['priority'] : 0;
40
                }
41
            }
42
43 1
            asort($processors);
44
45 1
            foreach ($processors as $id => $processor) {
46 1
                $definition->addMethodCall('add', array(
47 1
                    new Reference($id)
48
                ));
49
            }
50
        }
51 2
    }
52
}
53