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.

CommandStack   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 68
wmc 9
lcom 1
cbo 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A push() 0 4 1
A pop() 0 8 2
A getCurrentCommand() 0 4 2
A getMasterCommand() 0 8 2
A getParentCommand() 0 10 2
1
<?php
2
3
/**
4
 *
5
 * Copyright 2014 Simon Mönch.
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace APL\Dispatcher;
12
13
use APL\Command\CommandInterface;
14
15
/**
16
 *
17
 * @author David Badura <[email protected]>
18
 */
19
class CommandStack
20
{
21
22
    /**
23
     *
24
     * @var CommandInterface[]
25
     */
26
    private $commands = array();
27
28
    /**
29
     *
30
     * @param CommandInterface $command
31
     */
32
    public function push(CommandInterface $command)
33
    {
34
        $this->commands[] = $command;
35
    }
36
37
    /**
38
     *
39
     * @return CommandInterface
40
     */
41
    public function pop()
42
    {
43
        if (!$this->commands) {
44
            return null;
45
        }
46
47
        return array_pop($this->commands);
48
    }
49
50
    /**
51
     *
52
     * @return CommandInterface
53
     */
54
    public function getCurrentCommand()
55
    {
56
        return end($this->commands) ?: null;
57
    }
58
59
    /**
60
     *
61
     * @return CommandInterface
62
     */
63
    public function getMasterCommand()
64
    {
65
        if (!$this->commands) {
66
            return null;
67
        }
68
69
        return $this->commands[0];
70
    }
71
72
    /**
73
     *
74
     * @return CommandInterface
75
     */
76
    public function getParentCommand()
77
    {
78
        $pos = count($this->commands) - 2;
79
80
        if (!isset($this->commands[$pos])) {
81
            return null;
82
        }
83
84
        return $this->commands[$pos];
85
    }
86
}
87