LoggerAwarePass::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 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