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.

BasicBacktraceReporter::getBacktrace()   B
last analyzed

Complexity

Conditions 6
Paths 6

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 6.0087

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 22
ccs 15
cts 16
cp 0.9375
rs 8.6737
cc 6
eloc 14
nc 6
nop 1
crap 6.0087
1
<?php
2
3
namespace Camspiers\LoggerBridge\BacktraceReporter;
4
5
/**
6
 * Class BasicBacktraceReporter
7
 */
8
class BasicBacktraceReporter implements BacktraceReporter
9
{
10
    /**
11
     * Backtrace limit. Defaults to 0
12
     * @var int
13
     */
14
    protected $backtraceLimit = 0;
15
16
    /**
17
     * Sets the limit on the number of backtrace calls shown
18
     * @param int $backtraceLimit
19
     */
20 2
    public function setBacktraceLimit($backtraceLimit)
21
    {
22 2
        $this->backtraceLimit = (int) $backtraceLimit;
23 2
    }
24
25
    /**
26
     * Returns the backtrace limit
27
     * @return int
28
     */
29 1
    public function getBacktraceLimit()
30
    {
31 1
        return $this->backtraceLimit;
32
    }
33
34
    /**
35
     * Returns a basic backtrace
36
     * @param  \Exception $exception
37
     * @return array
38
     */
39 5
    public function getBacktrace(\Exception $exception = null)
40
    {
41 5
        $skipLimit = false;
42
43 5
        if ($exception instanceof \Exception) {
44 3
            $backtrace = $exception->getTrace();
45 3
            foreach ($backtrace as $index => $backtraceCall) {
46 3
                unset($backtrace[$index]['args']);
47 3
            }
48 5
        } elseif (version_compare(PHP_VERSION, '5.4.0') >= 0) {
49 2
            $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $this->backtraceLimit);
50 2
            $skipLimit = true;
51 2
        } else {
52
            $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
53
        }
54
55 5
        if ($this->backtraceLimit > 0 && !$skipLimit) {
56 1
            $backtrace = array_slice($backtrace, 0, $this->backtraceLimit);
57 1
        }
58
59 5
        return $backtrace;
60
    }
61
}
62