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.

Ahoi::createResourceOwner()   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
cc 1
nc 1
nop 2
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php namespace FVJM\OAuth2\Client\Provider;
2
3
use League\OAuth2\Client\Provider\AbstractProvider;
4
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
5
use League\OAuth2\Client\Token\AccessToken;
6
use League\OAuth2\Client\Tool\BearerAuthorizationTrait;
7
use Psr\Http\Message\ResponseInterface;
8
9
class Ahoi extends AbstractProvider
10
{
11
    use BearerAuthorizationTrait;
12
13
    /**
14
     * Default scopes
15
     *
16
     * @var array
17
     */
18
    public $defaultScopes = [];
19
20
    /**
21
     * Ahoi Instance URL version
22
     *
23
     * @var string
24
     */
25
    protected $ahoiInstanceUrl;
26
    /**
27
     * Get authorization url to begin OAuth flow
28
     *
29
     * @return string
30
     */
31 9
    public function getBaseAuthorizationUrl()
32
    {
33 9
        return "{$this->ahoiInstanceUrl}/authorize";
34
    }
35
36
    /**
37
     * Get access token url to retrieve token
38
     *
39
     * @return string
40
     */
41 12
    public function getBaseAccessTokenUrl(array $params)
42
    {
43 12
        return "{$this->ahoiInstanceUrl}/token";
44
    }
45
46
    /**
47
     * Get provider url to fetch user details
48
     *
49
     * @param  AccessToken $token
50
     *
51
     * @return string
52
     */
53 3
    public function getResourceOwnerDetailsUrl(AccessToken $token)
54
    {
55 3
        return "{$this->ahoiInstanceUrl}/me";
56
    }
57
58
    /**
59
     * Get the default scopes used by this provider.
60
     *
61
     * This should not be a complete list of all scopes, but the minimum
62
     * required for the provider user interface!
63
     *
64
     * @return array
65
     */
66 6
    protected function getDefaultScopes()
67
    {
68 6
        return $this->defaultScopes;
69
    }
70
71
    /**
72
     * Returns the string that should be used to separate scopes when building
73
     * the URL for requesting an access token.
74
     *
75
     * @return string Scope separator, defaults to ' '
76
     */
77 9
    protected function getScopeSeparator()
78
    {
79 9
        return ' ';
80
    }
81
82
    /**
83
     * Check a provider response for errors.
84
     *
85
     * @link https://api.ahoi.cloud/
86
     * @throws IdentityProviderException
87
     * @param  ResponseInterface $response
88
     * @param  string $data Parsed response data
89
     * @return void
90
     */
91 9
    protected function checkResponse(ResponseInterface $response, $data)
92
    {
93 9
        $acceptableStatuses = [200, 201];
94 9
        $data['message']=isset($data['message'])?$data['message']:null;
95 9
        if (!in_array($response->getStatusCode(), $acceptableStatuses)) {
96 3
            throw new IdentityProviderException(
97 3
                $data['message'] ?: $response->getReasonPhrase(),
98 3
                $response->getStatusCode(),
99 2
                $response
0 ignored issues
show
Documentation introduced by
$response is of type object<Psr\Http\Message\ResponseInterface>, but the function expects a array|string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
100 1
            );
101
        }
102 6
    }
103
104
    /**
105
     * Generate a user object from a successful user details request.
106
     *
107
     * @param object $response
108
     * @param AccessToken $token
109
     * @return League\OAuth2\Client\Provider\ResourceOwnerInterface
110
     */
111 3
    protected function createResourceOwner(array $response, AccessToken $token)
112
    {
113 3
        return new AhoiResourceOwner($response);
114
    }
115
}
116