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 ( 432e51...3131c6 )
by Cees-Jan
01:55
created

TraceProcessor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php declare(strict_types=1);
2
3
namespace WyriHaximus\Monolog\Processors;
4
5
use Throwable;
6
7
final class TraceProcessor
8
{
9
    /**
10
     * @var bool
11
     */
12
    private $always = false;
13
14
    /**
15
     * @param bool $always
16
     */
17 3
    public function __construct(bool $always = false)
18
    {
19 3
        $this->always = $always;
20 3
    }
21
22
    /**
23
     * @param  array $record
24
     * @return array
25
     */
26 3
    public function __invoke(array $record)
27
    {
28 3
        if (isset($record['context']['exception']) && $record['context']['exception'] instanceof Throwable) {
29 1
            $record['extra']['trace'] = $record['context']['exception']->getTrace();
30 1
            foreach ($record['extra']['trace'] as $index => $line) {
31 1
                if (!isset($line['args'])) {
32
                    continue;
33
                }
34
35 1
                unset($record['extra']['trace'][$index]['args']);
36
            }
37
        }
38
39 3
        if ($this->always && !isset($record['extra']['trace'])) {
40 1
            $record['extra']['trace'] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
41
        }
42
43 3
        return $record;
44
    }
45
}
46