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
Pull Request — master (#52)
by
unknown
19:57
created

CheckerRepository::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
rs 9.4285
nc 2
cc 2
eloc 4
nop 0
1
<?php
2
3
namespace Spatie\UptimeMonitor\Checker;
4
5
use Illuminate\Support\Collection;
6
use Spatie\UptimeMonitor\Exceptions\InvalidArgument;
7
8
/**
9
 * Created by PhpStorm.
10
 * User: lukaskammerling
11
 * Date: 28.11.16
12
 * Time: 10:28.
13
 */
14
class CheckerRepository
15
{
16
    /**
17
     * @var Collection
18
     */
19
    protected $protocolsToChecker = [];
20
21
22
    /**
23
     * @var
24
     */
25
    protected static $self;
26
27
    /**
28
     * @param $protocol
29
     * @param Checker $checker
30
     */
31
    public function addChecker($protocol, Checker $checker)
32
    {
33
        if (! array_key_exists($protocol, $this->protocolsToChecker)) {
34
            $this->protocolsToChecker[$protocol] = null;
35
        }
36
        if (! empty($this->protocolsToChecker[$protocol])) {
37
            throw InvalidArgument::checkerAlreadyRegisterd($protocol);
38
        }
39
        $this->protocolsToChecker[$protocol] = $checker;
40
    }
41
42
    /**
43
     * @param null $protocol
44
     * @return array
45
     */
46
    public function getChecker($protocol = null): array
47
    {
48
        if ($protocol != null) {
49
            if (array_key_exists($protocol, $this->protocolsToChecker)) {
50
                return $this->protocolsToChecker[$protocol];
51
            } else {
52
                throw InvalidArgument::unknowProtocol($protocol);
53
            }
54
        }
55
56
        return $this->protocolsToChecker;
57
    }
58
59
    /**
60
     * @return CheckerRepository
61
     */
62
    public static function get()
63
    {
64
        if (! self::$self instanceof self) {
65
            self::$self = new self();
66
        }
67
68
        return self::$self;
69
    }
70
}
71