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::__invoke()   B

Complexity

Conditions 7
Paths 4

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 7.049

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 9
cts 10
cp 0.9
rs 8.2222
c 0
b 0
f 0
cc 7
eloc 10
nc 4
nop 1
crap 7.049
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