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

Complexity

Total Complexity 12

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 69.23%

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 1
dl 0
loc 78
ccs 18
cts 26
cp 0.6923
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
A getScopes() 0 7 2
A getInfo() 0 4 1
A hasScope() 0 10 3
A jsonSerialize() 0 14 3
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