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 ( e97bb7...5f2eb5 )
by Pascal
10:40 queued 09:38
created

ApiHealthChecker   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 54
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fresh() 0 6 1
A isFailing() 0 14 3
A isPassing() 0 4 1
1
<?php
2
3
namespace ProtoneMedia\ApiHealth;
4
5
use ProtoneMedia\ApiHealth\Checkers\Executor;
6
use ProtoneMedia\ApiHealth\Storage\CheckerState;
7
8
class ApiHealthChecker
9
{
10
    /**
11
     * Boolean wether to use the state storage.
12
     *
13
     * @var bool
14
     */
15
    private $useStateStorage = true;
16
17
    /**
18
     * Disables the use of the state storage.
19
     *
20
     * @return $this
21
     */
22
    public function fresh()
23
    {
24
        $this->useStateStorage = false;
25
26
        return $this;
27
    }
28
29
    /**
30
     * Returns if the stored state is set to failed or runs the checker
31
     * if nothing is stored and returns wether the checker fails.
32
     *
33
     * @param  string $checkerClass
34
     * @return bool
35
     */
36
    public function isFailing(string $checkerClass): bool
37
    {
38
        if ($this->useStateStorage) {
39
            $storage = CheckerState::make($checkerClass);
40
41
            if ($storage->exists()) {
42
                return $storage->isFailing();
43
            }
44
        }
45
46
        $this->useStateStorage = true;
47
48
        return Executor::make($checkerClass)->fails();
49
    }
50
51
    /**
52
     * The opposite of the 'isFailing' method.
53
     *
54
     * @param  string $checkerClass
55
     * @return bool
56
     */
57
    public function isPassing(string $checkerClass): bool
58
    {
59
        return !$this->isFailing($checkerClass);
60
    }
61
}
62