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.

TempStack::isMaster()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Saltwater\Water;
4
5
class TempStack extends \ArrayObject
6
{
7
    /**
8
     * @var string
9
     */
10
    private $root = 'root';
11
12
    /**
13
     * @var string
14
     */
15
    private $master = 'root';
16
17
    public function __construct()
18
    {
19
        $this[] = $this->root;
20
    }
21
22
    /**
23
     * Set the root module by name
24
     *
25
     * @param string $name
26
     */
27
    public function setRoot($name)
28
    {
29
        if (empty($name) || ($name == $this->root)) {
30
            return;
31
        }
32
33
        $this->root = $name;
34
    }
35
36
    public function isRoot($name)
37
    {
38
        return $name == $this->root;
39
    }
40
41
    public function getRoot()
42
    {
43
        return $this->root;
44
    }
45
46
    /**
47
     * Set the master module by name
48
     *
49
     * @param string $name
50
     *
51
     * @return string previous master
52
     */
53
    public function setMaster($name)
54
    {
55
        if (empty($name) || ($name == $this->master)) {
56
            return $this->master;
57
        }
58
59
        $previous_master = $this->master;
60
61
        $this->master = $name;
62
63
        $this->pushStack($name);
64
65
        return $previous_master;
66
    }
67
68
    /**
69
     * Test whether a module name is the current master module
70
     *
71
     * @param string $name
72
     *
73
     * @return bool
74
     */
75
    public function isMaster($name)
76
    {
77
        return $name == $this->master;
78
    }
79
80
    /**
81
     * Get the name of the current master module
82
     *
83
     * @return string
84
     */
85
    public function getMaster()
86
    {
87
        return $this->master;
88
    }
89
90
    /**
91
     * Push a module name onto the stack, establishing later hierarchy for calls
92
     *
93
     * @param string $name
94
     */
95
    private function pushStack($name)
96
    {
97
        if (in_array($name, (array) $this)) {
98
            return;
99
        }
100
101
        $this[] = $name;
102
    }
103
104
    /**
105
     * Get the current ordered stack of modules that are loaded
106
     *
107
     * @return array
108
     */
109
    public function modulePrecedence()
110
    {
111
        $return = array();
112
        foreach ((array) $this as $module) {
113
            array_unshift($return, $module);
114
115
            if ($module == $this->master) {
116
                break;
117
            }
118
        }
119
120
        return $return;
121
    }
122
123
    /**
124
     * Jump to the next master or return false if we're already on it
125
     *
126
     * @return bool|string
127
     */
128
    public function advanceMaster()
129
    {
130
        $master = array_search($this->master, (array) $this);
131
132
        if ($master == ($this->count() - 1)) {
133
            return false;
134
        }
135
136
        $this->master = $this[$master + 1];
137
138
        return $this->master;
139
    }
140
}
141