GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( f6bb04...4c50ab )
by Hong
02:16
created

TerminalHandler   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 69
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 25 3
A setFormatter() 0 9 2
A isHandlingOther() 0 4 1
1
<?php
2
/**
3
 * Phossa Project
4
 *
5
 * PHP version 5.4
6
 *
7
 * @category  Library
8
 * @package   Phossa2\Logger
9
 * @copyright Copyright (c) 2016 phossa.com
10
 * @license   http://mit-license.org/ MIT License
11
 * @link      http://www.phossa.com/
12
 */
13
/*# declare(strict_types=1); */
14
15
namespace Phossa2\Logger;
16
17
use Phossa2\Logger\LogLevel;
18
use Phossa2\Logger\Message\Message;
19
use Phossa2\Logger\Handler\StreamHandler;
20
use Phossa2\Logger\Entry\LogEntryInterface;
21
use Phossa2\Logger\Exception\LogicException;
22
use Phossa2\Logger\Formatter\FormatterInterface;
23
use Phossa2\Logger\Formatter\AnsiColorFormatter;
24
25
/**
26
 * TerminalHandler
27
 *
28
 * Log to a terminal with or without ANSI color
29
 *
30
 * @package Phossa2\Logger
31
 * @author  Hong Zhang <[email protected]>
32
 * @see     StreamHandler
33
 * @version 2.0.0
34
 * @since   2.0.0 added
35
 */
36
class TerminalHandler extends StreamHandler
37
{
38
    /**
39
     * Use ANSI color or not
40
     *
41
     * @var    bool
42
     * @access protected
43
     */
44
    protected $color;
45
46
    /**
47
     * Constructor
48
     *
49
     * @param  string $stream the stream
50
     * @param  bool $color use ANSI color formatter or not
51
     * @param  string $logLevel
0 ignored issues
show
Bug introduced by
There is no parameter named $logLevel. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
52
     * @param  FormatterInterface $formatter
53
     * @param  bool $stopPropagation
54
     * @access public
55
     */
56
    public function __construct(
57
        /*# string */ $stream = 'php://stderr',
58
        /*# bool */ $color = true,
59
        /*# string */ $level = LogLevel::DEBUG,
60
        FormatterInterface $formatter = null,
61
        /*# bool */ $stopPropagation = false
62
    ) {
63
        // skip non-CLI mode
64
        if (!$this->isCliMode()) {
65
            return;
66
        }
67
68
        // use ansi color
69
        $this->color = (bool) $color;
70
71
        // check stream
72
        if (!in_array($stream, ['php://stderr', 'php://stdout'])) {
73
            throw new LogicException(
74
                Message::get(Message::LOG_STREAM_INVALID, $stream),
75
                Message::LOG_STREAM_INVALID
76
            );
77
        }
78
79
        parent::__construct($stream, $level, $formatter, $stopPropagation);
80
    }
81
82
    /**
83
     * Override default
84
     *
85
     * {@inheritDoc}
86
     */
87
    protected function setFormatter(FormatterInterface $formatter = null)
88
    {
89
        if ($this->color) {
90
            $this->formatter = new AnsiColorFormatter($formatter);
91
        } else {
92
            $this->formatter = $formatter;
93
        }
94
        return $this;
95
    }
96
97
    /**
98
     * {@inheritDoc}
99
     */
100
    protected function isHandlingOther(LogEntryInterface $logEntry)/*# : bool */
101
    {
102
        return $this->isCliMode();
103
    }
104
}
105