Completed
Push — master ( e22550...e221c0 )
by Matze
03:25
created

LoggerCompilerPass   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 13
Bugs 0 Features 4
Metric Value
wmc 2
c 13
b 0
f 4
lcom 0
cbo 3
dl 0
loc 21
rs 10
ccs 6
cts 6
cp 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 14 2
1
<?php
2
3
namespace BrainExe\Core\DependencyInjection\CompilerPass;
4
5
use BrainExe\Core\Annotations\CompilerPass;
6
use BrainExe\Core\Logger\ChannelStreamHandler;
7
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Definition;
10
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
11
12
/**
13
 * @CompilerPass
14
 */
15
class LoggerCompilerPass implements CompilerPassInterface
16
{
17
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function process(ContainerBuilder $container)
22
    {
23
        $logger = $container->getDefinition('logger');
24
25
        foreach ($container->getParameter('logger.channels') as $config) {
26 4
            $logger->addMethodCall('pushHandler', [
27
                new Definition(ChannelStreamHandler::class, $config)
28 4
            ]);
29
        }
30 4
31 1
        /** @var ParameterBag $parameterBag */
32 1
        $parameterBag = $container->getParameterBag();
33 1
        $parameterBag->remove('logger.channels');
34
    }
35
}
36