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   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 38
ccs 15
cts 15
cp 1
rs 10
c 1
b 0
f 0
wmc 7
lcom 1
cbo 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setNode() 0 6 2
A has() 0 4 1
A get() 0 8 2
A keys() 0 4 1
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