Completed
Push — master ( 70fc1a...2d4410 )
by Michael
02:52
created

setLogThresholdFromVerbosity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 16
rs 9.4285
cc 1
eloc 10
nc 1
nop 1
1
<?php
2
/**
3
 * Contains trait VerbosityToStrategyTrait.
4
 *
5
 * PHP version 5.5
6
 *
7
 * LICENSE:
8
 * This file is part of Yet Another Php Eve Api Library also know as Yapeal
9
 * which can be used to access the Eve Online API data and place it into a
10
 * database.
11
 * Copyright (C) 2016 Michael Cummings
12
 *
13
 * This program is free software: you can redistribute it and/or modify it
14
 * under the terms of the GNU Lesser General Public License as published by the
15
 * Free Software Foundation, either version 3 of the License, or (at your
16
 * option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful, but WITHOUT
19
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
21
 * for more details.
22
 *
23
 * You should have received a copy of the GNU Lesser General Public License
24
 * along with this program. If not, see
25
 * <http://www.gnu.org/licenses/>.
26
 *
27
 * You should be able to find a copy of this license in the LICENSE.md file. A
28
 * copy of the GNU GPL should also be available in the GNU-GPL.md file.
29
 *
30
 * @copyright 2016 Michael Cummings
31
 * @license   LGPL-3.0+
32
 * @author    Michael Cummings <[email protected]>
33
 */
34
namespace Yapeal\Console\Command;
35
36
use Symfony\Component\Console\Output\OutputInterface;
37
use Yapeal\Container\ContainerInterface;
38
use Yapeal\Log\Logger;
39
40
/**
41
 * Trait VerbosityToStrategyTrait.
42
 *
43
 * @method ContainerInterface getDic()
44
 */
45
trait VerbosityToStrategyTrait
46
{
47
    /**
48
     * @param OutputInterface $output
49
     *
50
     * @return $this Fluent Interface.
51
     * @throws \LogicException
52
     */
53
    protected function setLogThresholdFromVerbosity(OutputInterface $output)
54
    {
55
        $map = [
56
            $output::VERBOSITY_QUIET => Logger::ERROR,
57
            $output::VERBOSITY_NORMAL => Logger::WARNING,
58
            $output::VERBOSITY_VERBOSE => Logger::NOTICE,
59
            $output::VERBOSITY_VERY_VERBOSE => Logger::INFO,
60
            $output::VERBOSITY_DEBUG => Logger::DEBUG
61
        ];
62
        /**
63
         * @var \Yapeal\Log\ActivationStrategy $strategy
64
         */
65
        $strategy = $this->getDic()['Yapeal.Log.Strategy'];
66
        $strategy->setActionLevel($map[$output->getVerbosity()]);
67
        return $this;
68
    }
69
}
70