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.

Backtrace::extractCaller()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
c 0
b 0
f 0
rs 9.2
cc 4
eloc 8
nc 3
nop 0
1
<?php
2
3
namespace Saltwater\Water;
4
5
use Saltwater\Server as S;
6
7
class Backtrace extends \ArrayIterator
8
{
9
    /** @var string[] skipped classes during search for caller module */
10
    private static $skip = array(
11
        'Saltwater\Navigator',
12
        'Saltwater\Server'
13
    );
14
15
    public function __construct()
16
    {
17
        // Let me tell you about my boat
18
        if (S::$env['gt54']) {
19
            return parent::__construct(debug_backtrace(2, 22));
0 ignored issues
show
Bug introduced by
Constructors do not have meaningful return values, anything that is returned from here is discarded. Are you sure this is correct?
Loading history...
20
        } else {
21
            return parent::__construct(debug_backtrace(false));
0 ignored issues
show
Bug introduced by
Constructors do not have meaningful return values, anything that is returned from here is discarded. Are you sure this is correct?
Loading history...
22
        }
23
    }
24
25
    /**
26
     * Shorthand for generating a Backtrace and returning the last caller
27
     *
28
     * @return array|null
29
     */
30
    public static function lastCaller()
31
    {
32
        $backtrace = new Backtrace;
33
34
        return $backtrace->extractCaller();
35
    }
36
37
    /**
38
     * Find and extract the last non-saltwater core class calling
39
     *
40
     * @return array|null
41
     */
42
    public function extractCaller()
43
    {
44
        while ($this->valid()) {
45
            $current = $this->current();
46
47
            if (
48
                isset($current['class'])
49
                && !$this->skipCaller($current['class'])
50
            ) {
51
                return explode('\\', $current['class']);
52
            }
53
        }
54
55
        return S::$n->modules->getStack()->getMaster();
56
    }
57
58
    /**
59
     * Check whether a caller class can be skipped
60
     *
61
     * @param string $class
62
     *
63
     * @return bool
64
     */
65
    private function skipCaller($class)
66
    {
67
        return (strpos($class, 'Saltwater\Root') !== false)
68
            || (strpos($class, '\\') === false)
69
            || in_array($class, self::$skip);
70
    }
71
}
72