LoggerAwarePass   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 7
dl 0
loc 17
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 7 2
1
<?php
2
3
namespace Norsys\LogsBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Reference;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
9
/**
10
 * Class LoggerAwarePass
11
 * Helper to set logger for the classes using LoggerAwareTrait
12
 */
13
class LoggerAwarePass implements CompilerPassInterface
14
{
15
    /**
16
     * @var string
17
     */
18
    const REFERENCE = 'logger.aware';
19
20
    /**
21
     * @param ContainerBuilder $container
22
     */
23
    public function process(ContainerBuilder $container)
24
    {
25 1
        $logger = new Reference('logger');
26 1
        $taggedServices = $container->findTaggedServiceIds(self::REFERENCE);
27 1
        foreach ($taggedServices as $id => $tags) {
28 1
            $definition = $container->getDefinition($id);
29 1
            $definition->addMethodCall('setLogger', [ $logger ]);
30
        }
31 1
    }
32
}
33