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.

CommandsCollection::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 2
rs 9.4285
c 1
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * This file is part of PhuninNode.
6
 *
7
 ** (c) 2013 - 2016 Cees-Jan Kiewiet
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace WyriHaximus\PhuninNode;
14
15
use WyriHaximus\PhuninNode\Commands\CommandInterface;
16
17
class CommandsCollection
18
{
19
    /**
20
     * @var array
21
     */
22
    protected $commands;
23
24 53
    public function __construct(array $commands)
25
    {
26 53
        $this->commands = $commands;
27 53
    }
28
29 47
    public function setNode(Node $node)
30
    {
31 47
        foreach ($this->commands as $command) {
32 47
            $command->setNode($node);
33
        }
34 47
    }
35
36 5
    public function has($command): bool
37
    {
38 5
        return isset($this->commands[$command]);
39
    }
40
41 4
    public function get($command): CommandInterface
42
    {
43 4
        if (!$this->has($command)) {
44 1
            throw new \Exception();
45
        }
46
47 3
        return $this->commands[$command];
48
    }
49
50 3
    public function keys(): array
51
    {
52 3
        return array_keys($this->commands);
53
    }
54
}
55