Completed
Push — master ( c6b4ff...ac8b0a )
by Nikola
04:16
created

RatesConfigurationRegistryCompilerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3.0261

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 15
ccs 6
cts 7
cp 0.8571
rs 9.4285
c 1
b 0
f 1
cc 3
eloc 7
nc 3
nop 1
crap 3.0261
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 RatesConfigurationRegistryCompilerPass
18
 *
19
 * @package RunOpenCode\Bundle\ExchangeRate\DependencyInjection\CompilerPass
20
 */
21
class RatesConfigurationRegistryCompilerPass implements CompilerPassInterface
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26 1
    public function process(ContainerBuilder $container)
27
    {
28
29 1
        if (!$container->hasDefinition('runopencode.exchange_rate.registry.rates')) {
30
            return;
31
        }
32
33 1
        $registry = $container->findDefinition('runopencode.exchange_rate.registry.rates');
34
35 1
        foreach (array_keys($container->findTaggedServiceIds('runopencode.exchange_rate.rate_configuration')) as $id) {
36
37
            $registry
38 1
                ->addMethodCall('add', [new Reference($id)]);
39
        }
40 1
    }
41
}
42