Completed
Push — master ( 19ba56...bf992c )
by Tobias
06:15
created

ProfilerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 9.8666
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 3
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the BazingaGeocoderBundle package.
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license    MIT License
11
 */
12
13
namespace Bazinga\GeocoderBundle\DependencyInjection\Compiler;
14
15
use Bazinga\GeocoderBundle\DataCollector\GeocoderDataCollector;
16
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
use Symfony\Component\DependencyInjection\Reference;
19
20
/**
21
 * Add Profiling on all providers with that 'bazinga_geocoder.provider'.
22
 *
23
 * @author Tobias Nyholm <[email protected]>
24
 */
25
class ProfilerPass implements CompilerPassInterface
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30 26
    public function process(ContainerBuilder $container)
31
    {
32 26
        if (!$container->hasDefinition(GeocoderDataCollector::class)) {
33 24
            return;
34
        }
35
36 2
        $dataCollector = $container->getDefinition(GeocoderDataCollector::class);
37
38 2
        foreach ($container->findTaggedServiceIds('bazinga_geocoder.profiling_plugin') as $providerId => $attributes) {
39 1
            $dataCollector->addMethodCall('addInstance', [new Reference($providerId)]);
40
        }
41 2
    }
42
}
43