Completed
Push — master ( a814e0...392de1 )
by Tobias
24:09
created

ProfilerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 21
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 15 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
namespace Bazinga\Bundle\GeocoderBundle\DependencyInjection\Compiler;
11
12
use Bazinga\Bundle\GeocoderBundle\DataCollector\GeocoderDataCollector;
13
use Bazinga\Bundle\GeocoderBundle\DataCollector\ProfilingProvider;
14
use Bazinga\Bundle\GeocoderBundle\Logger\GeocoderLogger;
15
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Reference;
18
19
/**
20
 * Add Profiling on all providers with that 'bazinga_geocoder.provider'
21
 *
22
 * @author Tobias Nyholm <[email protected]>
23
 */
24
class ProfilerPass implements CompilerPassInterface
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function process(ContainerBuilder $container)
30
    {
31
        if (!$container->hasDefinition(GeocoderDataCollector::class)) {
32
            return;
33
        }
34
35
        foreach ($container->findTaggedServiceIds('bazinga_geocoder.provider') as $providerId => $attributes) {
36
            $container->register($providerId.'.debug', ProfilingProvider::class)
37
                ->setDecoratedService($providerId)
38
                ->setArguments([
39
                    new Reference($providerId.'.debug.inner'),
40
                    new Reference(GeocoderLogger::class)
41
                ]);
42
        }
43
    }
44
}
45