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

ProfilerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 18
ccs 6
cts 7
cp 0.8571
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 12 3
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