Completed
Pull Request — master (#59)
by Julien
02:49
created

LogLevelConfigurator::configureLogLevel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace TheAentMachine\Helper;
5
6
use Symfony\Component\Console\Output\OutputInterface;
7
use TheAentMachine\Exception\LogLevelException;
8
use TheAentMachine\Aenthill\Pheromone;
9
10
class LogLevelConfigurator
11
{
12
    /** @var array */
13
    private $levels = [
14
        'DEBUG' => OutputInterface::VERBOSITY_DEBUG,
15
        'INFO' => OutputInterface::VERBOSITY_VERY_VERBOSE,
16
        'WARN' => OutputInterface::VERBOSITY_VERBOSE,
17
        'ERROR' => OutputInterface::VERBOSITY_NORMAL,
18
    ];
19
20
    /** @var OutputInterface */
21
    private $output;
22
23
    /**
24
     * Log constructor.
25
     * @param OutputInterface $output
26
     */
27
    public function __construct(OutputInterface $output)
28
    {
29
        $this->output = $output;
30
    }
31
32
    /**
33
     * @throws LogLevelException
34
     * @return void
35
     */
36
    public function configureLogLevel(): void
37
    {
38
        $logLevel = Pheromone::getLogLevel();
39
        $this->output->setVerbosity($this->levels[$logLevel]);
40
    }
41
}
42