Completed
Push — master ( f6cc4f...20183c )
by Andrii
03:46
created

OldConsoleTarget::out()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 7

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 11
loc 11
ccs 0
cts 11
cp 0
rs 9.4285
cc 3
eloc 7
nc 3
nop 2
crap 12
1
<?php
2
/**
3
 * Automation tool mixed with code generator for easier continuous development
4
 *
5
 * @link      https://github.com/hiqdev/hidev
6
 * @package   hidev
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hidev\log;
12
13
use Yii;
14
use yii\helpers\Console;
15
use yii\log\Logger;
16
17
class OldConsoleTarget extends \yii\log\Target
18
{
19
    public $exportInterval = 1;
20
21
    public static $styles = [
22
        Logger::LEVEL_WARNING => [Console::FG_YELLOW],
23
        Logger::LEVEL_ERROR   => [Console::FG_RED],
24
    ];
25
26
    public function export()
27
    {
28
        foreach ($this->messages as $message) {
29
            $this->out($message[0], $message[1]);
30
        }
31
    }
32
33 View Code Duplication
    public function out($message, $level)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
    {
35
        if ($level > $this->getLevel()) {
36
            return;
37
        }
38
        $style = self::$styles[$level];
39
        if ($style) {
40
            $message = Console::ansiFormat($message, $style);
41
        }
42
        Console::stdout($message . "\n");
43
    }
44
45
    public function getLevel()
46
    {
47
        return Yii::$app->get('log')->getLevel();
48
    }
49
50
    protected function getContextMessage()
51
    {
52
        return '';
53
    }
54
}
55