LoggerProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A register() 0 10 1
1
<?php
2
namespace Metfan\RabbitSetup\Container;
3
4
use Pimple\Container;
5
use Pimple\ServiceProviderInterface;
6
use Psr\Log\LogLevel;
7
use Symfony\Component\Console\Logger\ConsoleLogger;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
11
/**
12
 * Override Logger defintion in container with ConsoleLogger
13
 *
14
 * @author Ulrich
15
 * @package Metfan\RabbitSetup\Container
16
 */
17
class LoggerProvider implements ServiceProviderInterface
18
{
19
    /**
20
     * @var OutputInterface
21
     */
22
    private $output;
23
24
    public function __construct(OutputInterface $output)
25
    {
26
        $this->output = $output;
27
    }
28
29
    public function register(Container $container)
30
    {
31
        $container['command_output'] = $this->output;
32
        $container['logger'] = function($c){
33
            return new ConsoleLogger(
34
                $c['command_output'],
35
                [LogLevel::INFO => OutputInterface::VERBOSITY_NORMAL],
36
                [LogLevel::INFO => null]);
37
        };
38
    }
39
}
40