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 ( deffcb...b633e9 )
by Anton
02:17
created

Context::getInput()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/* (c) Anton Medvedev <[email protected]>
3
 *
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace Deployer\Task;
9
10
use Deployer\Configuration\Configuration;
11
use Deployer\Exception\Exception;
12
use Deployer\Host\Host;
13
use Symfony\Component\Console\Input\InputInterface;
14
use Symfony\Component\Console\Output\OutputInterface;
15
16
class Context
17
{
18
    /**
19
     * @var Host
20
     */
21
    private $host;
22
23
    /**
24
     * @var InputInterface
25
     */
26
    private $input;
27
28
    /**
29
     * @var OutputInterface
30
     */
31
    private $output;
32
33
    /**
34
     * @var Context[]
35
     */
36
    private static $contexts = [];
37
38
    /**
39
     * @param Host $host
40
     * @param InputInterface $input
41
     * @param OutputInterface $output
42
     */
43 19
    public function __construct($host, InputInterface $input = null, OutputInterface $output = null)
44
    {
45 19
        $this->host = $host;
46 19
        $this->input = $input;
47 19
        $this->output = $output;
48 19
    }
49
50
    /**
51
     * @param Context $context
52
     */
53 21
    public static function push(Context $context)
54
    {
55 21
        self::$contexts[] = $context;
56 21
    }
57
58
    /**
59
     * @return bool
60
     */
61 14
    public static function has()
62
    {
63 14
        return !empty(self::$contexts);
64
    }
65
66
    /**
67
     * @return Context|false
68
     * @throws Exception
69
     */
70 14
    public static function get()
71
    {
72 14
        if (empty(self::$contexts)) {
73
            throw new Exception('Context was required, but there\'s nothing there.');
74
        }
75 14
        return end(self::$contexts);
76
    }
77
78
    /**
79
     * @return Context
80
     */
81 21
    public static function pop()
82
    {
83 21
        return array_pop(self::$contexts);
84
    }
85
86
    /**
87
     * Throws a Exception when not called within a task-context and therefore no Context is available.
88
     *
89
     * This method provides a useful error to the end-user to make him/her aware
90
     * to use a function in the required task-context.
91
     *
92
     * @param string $callerName
93
     * @throws Exception
94
     */
95 1
    public static function required($callerName)
96
    {
97 1
        if (empty(self::$contexts)) {
98
            throw new Exception("'$callerName' can only be used within a task.");
99
        }
100 1
    }
101
102
    /**
103
     * @return Configuration
104
     */
105 13
    public function getConfig()
106
    {
107 13
        return $this->host->getConfig();
108
    }
109
110
    /**
111
     * @return InputInterface
112
     */
113 6
    public function getInput()
114
    {
115 6
        return $this->input;
116
    }
117
118
    /**
119
     * @return OutputInterface
120
     */
121 10
    public function getOutput()
122
    {
123 10
        return $this->output;
124
    }
125
126
    /**
127
     * @return Host
128
     */
129 12
    public function getHost()
130
    {
131 12
        return $this->host;
132
    }
133
}
134