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.

DigitalOceanAccessToken::getInfo()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace ChrisHemmings\OAuth2\Client\Token;
4
5
use League\OAuth2\Client\Token\AccessToken;
6
7
class DigitalOceanAccessToken extends AccessToken
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $scope;
13
14
    /**
15
     * @var array
16
     */
17
    protected $info;
18
19
    /**
20
     * @inheritDoc
21
     */
22 6
    public function __construct(array $options = [])
23
    {
24 6
        if (!empty($options['scope'])) {
25 3
            $this->scope = $options['scope'];
26
        }
27 6
        if (!empty($options['info'])) {
28 3
            $this->info = $options['info'];
29
        }
30 6
        parent::__construct($options);
31 6
    }
32
33
    /**
34
     * @return string[]
35
     */
36 3
    public function getScopes()
37
    {
38 3
        if (empty($this->scope)) {
39
            return [];
40
        }
41 3
        return array_filter(explode(' ', $this->scope));
42
    }
43
44
    /**
45
     * @return array|null
46
     */
47 3
    public function getInfo()
48
    {
49 3
        return $this->info;
50
    }
51
52
    /**
53
     * @param string $scope
54
     * @return bool
55
     */
56 3
    public function hasScope($scope)
57
    {
58 3
        $scope = trim(strtolower($scope));
59 3
        foreach ($this->getScopes() as $candidate) {
60 3
            if ($scope === strtolower(trim($candidate))) {
61 3
                return true;
62
            }
63
        }
64 3
        return false;
65
    }
66
67
    /**
68
     * @inheritdoc
69
     */
70
    public function jsonSerialize()
71
    {
72
        $parameters = parent::jsonSerialize();
73
74
        if ($this->scope) {
75
            $parameters['scope'] = $this->scope;
76
        }
77
78
        if (!empty($this->info)) {
79
            $parameters['info'] = $this->info;
80
        }
81
82
        return $parameters;
83
    }
84
}
85