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.

Context   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Test Coverage

Coverage 92.86%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 60
rs 10
c 0
b 0
f 0
ccs 13
cts 14
cp 0.9286
wmc 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A push() 0 3 1
A __construct() 0 3 1
A getConfig() 0 3 1
A has() 0 3 1
A getHost() 0 3 1
A required() 0 4 2
A pop() 0 3 1
A get() 0 6 2
1
<?php
2
3
declare(strict_types=1);
4
5
/* (c) Anton Medvedev <[email protected]>
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 Deployer\Task;
12
13
use Deployer\Configuration;
14
use Deployer\Exception\Exception;
15
use Deployer\Host\Host;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Output\OutputInterface;
18
19
class Context
20
{
21
    private Host $host;
22
23
    /**
24
     * @var Context[]
25
     */
26
    private static array $contexts = [];
27
28
    public function __construct(Host $host)
29
    {
30
        $this->host = $host;
31
    }
32
33
    public static function push(Context $context): void
34
    {
35
        self::$contexts[] = $context;
36
    }
37
38
    public static function has(): bool
39
    {
40
        return !empty(self::$contexts);
41
    }
42
43 17
    public static function get(): Context
44
    {
45 17
        if (empty(self::$contexts)) {
46 17
            throw new Exception("Context was requested but was not available.");
47 17
        }
48 17
        return end(self::$contexts);
49
    }
50
51
    public static function pop(): ?Context
52
    {
53 19
        return array_pop(self::$contexts);
54
    }
55 19
56 19
    /**
57
     * Throws a Exception when not called within a task-context and therefore no Context is available.
58
     *
59
     * This method provides a useful error to the end-user to make him/her aware
60
     * to use a function in the required task-context.
61 14
     *
62
     * @throws Exception
63 14
     */
64
    public static function required(string $callerName): void
65
    {
66
        if (empty(self::$contexts)) {
67
            throw new Exception("'$callerName' can only be used within a task.");
68
        }
69
    }
70 12
71
    public function getConfig(): Configuration
72 12
    {
73
        return $this->host->config();
74
    }
75 12
76
    public function getHost(): Host
77
    {
78
        return $this->host;
79
    }
80
}
81