Completed
Push — master ( 6c4efe...df4b6e )
by Tobias
08:17
created

ProfilerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3.0261

Importance

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