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 ( 4c50ab...acecb4 )
by Hong
02:37
created

TerminalHandler::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 20
rs 9.4285
cc 3
eloc 14
nc 3
nop 5
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 $level
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
        if (!$this->isCliMode()) {
64
            return;
65
        }
66
        $this->color = (bool) $color;
67
68
        if (!in_array($stream, ['php://stderr', 'php://stdout'])) {
69
            throw new LogicException(
70
                Message::get(Message::LOG_STREAM_INVALID, $stream),
71
                Message::LOG_STREAM_INVALID
72
            );
73
        }
74
        parent::__construct($stream, $level, $formatter, $stopPropagation);
75
    }
76
77
    /**
78
     * Override default
79
     *
80
     * {@inheritDoc}
81
     */
82
    protected function setFormatter(FormatterInterface $formatter = null)
83
    {
84
        if ($this->color) {
85
            $this->formatter = new AnsiColorFormatter($formatter);
86
        } else {
87
            $this->formatter = $formatter;
88
        }
89
        return $this;
90
    }
91
92
    /**
93
     * {@inheritDoc}
94
     */
95
    protected function isHandlingOther(LogEntryInterface $logEntry)/*# : bool */
96
    {
97
        return $this->isCliMode();
98
    }
99
}
100