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 ( 5802ed...900bc8 )
by Hong
02:38
created

LogEntry::getFormatted()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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\Entry;
16
17
use Phossa2\Logger\LogLevel;
18
use Phossa2\Logger\Message\Message;
19
use Psr\Log\LogLevel as PsrLogLevel;
20
use Phossa2\Shared\Base\ObjectAbstract;
21
use Phossa2\Logger\Formatter\DefaultFormatter;
22
use Phossa2\Logger\Exception\InvalidArgumentException;
23
24
/**
25
 * LogEntry
26
 *
27
 * @package Phossa2\Logger
28
 * @author  Hong Zhang <[email protected]>
29
 * @see     ObjectAbstract
30
 * @see     LogEntryInterface
31
 * @version 2.0.0
32
 * @since   2.0.0 added
33
 */
34
class LogEntry extends ObjectAbstract implements LogEntryInterface
35
{
36
    /**
37
     * @var    string
38
     * @access protected
39
     */
40
    protected $channel;
41
42
    /**
43
     * @var    string
44
     * @access protected
45
     */
46
    protected $message;
47
48
    /**
49
     * @var    string
50
     * @access protected
51
     */
52
    protected $level;
53
54
    /**
55
     * @var    array
56
     * @access protected
57
     */
58
    protected $context;
59
60
    /**
61
     * @var    string
62
     * @access protected
63
     */
64
    protected $formatted;
65
66
    /**
67
     * @var    float
68
     * @access protected
69
     */
70
    protected $timestamp;
71
72
    /**
73
     * is log stopped propagation ?
74
     *
75
     * @var    bool
76
     * @access protected
77
     */
78
    protected $stopped = false;
79
80
    /**
81
     * Create the log entry
82
     *
83
     * @param  string $channel
84
     * @param  string $level
85
     * @param  string $message
86
     * @param  array $context
87
     * @param  float $timestamp
88
     * @throws InvalidArgumentException if level invalid
89
     * @access protected
90
     */
91
    public function __construct(
92
        /*# string */ $channel,
93
        /*# string */ $level,
94
        /*# string */ $message,
95
        array $context = [],
96
        /*# float */ $timestamp = 0
97
    ) {
98
        $this
99
            ->setChannel($channel)
100
            ->setLevel($level)
101
            ->setMessage($message)
102
            ->setContext($context)
103
            ->setTimestamp($timestamp);
104
    }
105
106
    /**
107
     * {@inheritDoc}
108
     */
109
    public function setChannel(
110
        /*# string */ $channel
111
    ) {
112
        $this->channel = $channel;
113
        return $this;
114
    }
115
116
    /**
117
     * {@inheritDoc}
118
     */
119
    public function getChannel()/*# : string */
120
    {
121
        return $this->channel;
122
    }
123
124
    /**
125
     * {@inheritDoc}
126
     */
127
    public function setMessage(
128
        /*# string */ $message
129
    ) {
130
        $this->message = (string) $message;
131
        return $this;
132
    }
133
134
    /**
135
     * {@inheritDoc}
136
     */
137
    public function getMessage()/*# : string */
138
    {
139
        return $this->message;
140
    }
141
142
    /**
143
     * {@inheritDoc}
144
     */
145
    public function setLevel(
146
        /*# string */ $level = PsrLogLevel::INFO
147
    ) {
148
        if (!isset(LogLevel::$levels[$level])) {
149
            throw new InvalidArgumentException(
150
                Message::get(Message::LOG_LEVEL_INVALID, $level),
151
                Message::LOG_LEVEL_INVALID
152
            );
153
        }
154
        $this->level = $level;
155
        return $this;
156
    }
157
158
    /**
159
     * {@inheritDoc}
160
     */
161
    public function getLevel()/*# : string */
162
    {
163
        return $this->level;
164
    }
165
166
    /**
167
     * {@inheritDoc}
168
     */
169
    public function setFormatted(/*# string */ $formatted)
170
    {
171
        $this->formatted = $formatted;
172
        return $this;
173
    }
174
175
    /**
176
     * {@inheritDoc}
177
     */
178
    public function getFormatted()/*# string */
179
    {
180
        return $this->formatted;
181
    }
182
183
    /**
184
     * {@inheritDoc}
185
     */
186
    public function setTimestamp(
187
        /*# : float */ $timestamp = 0
188
    ) {
189
        $this->timestamp = (float) ($timestamp ?: microtime(true));
190
        return $this;
191
    }
192
193
    /**
194
     * {@inheritDoc}
195
     */
196
    public function getTimestamp()/*# : float */
197
    {
198
         return $this->timestamp;
199
    }
200
201
    /**
202
     * {@inheritDoc}
203
     */
204
    public function setContext(array $context)
205
    {
206
        $this->context = $context;
207
        return $this;
208
    }
209
210
    /**
211
     * {@inheritDoc}
212
     */
213
    public function getContext()/*# : array */
214
    {
215
        return $this->context;
216
    }
217
218
    /**
219
     * {@inheritDoc}
220
     */
221
    public function stopPropagation(/*# : bool */ $flag = true)
222
    {
223
        $this->stopped = (bool) $flag;
224
        return $this;
225
    }
226
227
    /**
228
     * {@inheritDoc}
229
     */
230
    public function isPropagationStopped()/*# : bool */
231
    {
232
        return $this->stopped;
233
    }
234
235
    /**
236
     * Use the default formatter
237
     *
238
     * {@inheritDoc}
239
     */
240
    public function __toString()/*# : string */
241
    {
242
        $formatter = new DefaultFormatter();
243
        return $formatter($this);
244
    }
245
}
246