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.

Console::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Gear;
15
16
// ------------------------------------------------------------------------
17
18
/**
19
 * O2System Gear Console
20
 *
21
 * @package O2System\Gear
22
 */
23
class Console
24
{
25
    /**
26
     * Console::LOG_MESSAGE
27
     *
28
     * @var int
29
     */
30
    const LOG_MESSAGE = 0;
31
32
    /**
33
     * Console::LOG_MESSAGE
34
     *
35
     * @var int
36
     */
37
    const INFO_MESSAGE = 1;
38
39
    /**
40
     * Console::LOG_MESSAGE
41
     *
42
     * @var int
43
     */
44
    const WARNING_MESSAGE = 2;
45
46
    /**
47
     * Console::LOG_MESSAGE
48
     *
49
     * @var int
50
     */
51
    const ERROR_MESSAGE = 3;
52
53
    /**
54
     * Console::LOG_MESSAGE
55
     *
56
     * @var int
57
     */
58
    const DEBUG_MESSAGE = 4;
59
60
    // ------------------------------------------------------------------------
61
62
    /**
63
     * Console::$label
64
     *
65
     * @var string
66
     */
67
    private $label;
68
69
    /**
70
     * Console::$expression
71
     *
72
     * @var mixed
73
     */
74
    private $expression;
75
76
    /**
77
     * Console::$messageType
78
     *
79
     * @var int
80
     */
81
    private $messageType;
82
83
    // ------------------------------------------------------------------------
84
85
    /**
86
     * Console::__construct
87
     *
88
     * @param string   $label
89
     * @param mixed    $expression
90
     * @param int      $messageType
91
     */
92
    public function __construct($label, $expression, $messageType = self::LOG_MESSAGE)
93
    {
94
        $this->label = $label;
95
        $this->expression = $expression;
96
        $this->messageType = $messageType;
97
    }
98
99
    // ------------------------------------------------------------------------
100
101
    /**
102
     * Console::send
103
     */
104
    public function send()
105
    {
106
        $this->expression = is_object($this->expression) || is_array($this->expression)
107
            ? 'JSON.parse(\'' . json_encode(
108
                $this->expression
109
            ) . '\')'
110
            : '\'' . $this->expression . '\'';
111
112
        echo '<script type="text/javascript">' . PHP_EOL;
113
114
        switch ($this->messageType) {
115
            default:
116
            case self::LOG_MESSAGE :
117
                $messageType = 'log';
118
                $backgroundColor = '#777777';
119
                $textColor = '#ffffff';
120
                break;
121
            case self::INFO_MESSAGE :
122
                $messageType = 'info';
123
                $backgroundColor = '#5bc0de';
124
                $textColor = '#ffffff';
125
                break;
126
            case self::WARNING_MESSAGE :
127
                $messageType = 'warn';
128
                $backgroundColor = '#f0ad4e';
129
                $textColor = '#ffffff';
130
                break;
131
            case self::ERROR_MESSAGE :
132
                $messageType = 'error';
133
                $backgroundColor = '#d9534f';
134
                $textColor = '#ffffff';
135
                break;
136
            case self::DEBUG_MESSAGE :
137
                $messageType = 'debug';
138
                $backgroundColor = '#333333';
139
                $textColor = '#ffffff';
140
                break;
141
        }
142
143
        if ( ! empty($this->label)) {
144
            echo "console." . $messageType . "('%c " . $this->label . " ', 'background: " . $backgroundColor . "; color: " . $textColor . "');" . PHP_EOL;
145
        }
146
147
        echo "console." . $messageType . "(" . $this->expression . ");" . PHP_EOL;
148
149
        echo '</script>' . PHP_EOL;
150
    }
151
}