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.

Shopify   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 112
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 5
dl 0
loc 112
ccs 29
cts 29
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 2
A getBaseAuthorizationUrl() 0 4 1
A getBaseAccessTokenUrl() 0 4 1
A getResourceOwnerDetailsUrl() 0 8 1
A getDefaultScopes() 0 7 1
A checkResponse() 0 10 3
A createResourceOwner() 0 6 1
1
<?php namespace Pizdata\OAuth2\Client\Provider;
2
3
use Psr\Http\Message\ResponseInterface;
4
use League\OAuth2\Client\Token\AccessToken;
5
use League\OAuth2\Client\Provider\AbstractProvider;
6
use Pizdata\OAuth2\Client\Exception\ShopifyIdentityProviderException;
7
8
class Shopify extends AbstractProvider
9
{
10
    /**
11
     * The store name.
12
     *
13
     * @var string
14
     */
15
    public $store = '';
16
17
    /**
18
     * @param array $options
19
     * @param array $collaborators
20
     *
21
     * @throws \InvalidArgumentException
22
     */
23 6
    public function __construct($options = [], array $collaborators = [])
24
    {
25 6
        parent::__construct($options, $collaborators);
26
27 6
        if (empty($options['shop'])) {
28 3
            $message = 'The "shop" option not set. Please set a Shop name.';
29 3
            throw new \InvalidArgumentException($message);
30
        }
31
32 6
        $this->store = $options['shop'];
33 6
    }
34
35
    /**
36
     * Get authorization url to begin OAuth flow
37
     *
38
     * @return string
39
     */
40 3
    public function getBaseAuthorizationUrl()
41
    {
42 3
        return sprintf('https://%s/admin/oauth/authorize', $this->store);
43
    }
44
45
    /**
46
     * Get access token url to retrieve token
47
     *
48
     * @param  array $params
49
     *
50
     * @return string
51
     */
52 6
    public function getBaseAccessTokenUrl(array $params)
53
    {
54 6
        return sprintf('https://%s/admin/oauth/access_token', $this->store);
55
    }
56
57
    /**
58
     * Get provider url to fetch user details
59
     *
60
     * @param  AccessToken $token
61
     *
62
     * @return string
63
     */
64 6
    public function getResourceOwnerDetailsUrl(AccessToken $token)
65
    {
66 6
        return sprintf(
67 6
            'https://%s/admin/shop.json?access_token=%s',
68 6
            $this->store,
69 6
            $token->getToken()
70 4
        );
71
    }
72
73
    /**
74
     * Get the default scopes used by this provider.
75
     *
76
     * @link https://help.shopify.com/api/getting-started/authentication/oauth#scopes
77
     * @return array
78
     */
79 3
    protected function getDefaultScopes()
80
    {
81
        return [
82 3
            'read_orders',
83
            'read_products'
84 2
        ];
85
    }
86
87
    /**
88
     * Check a provider response for errors.
89
     *
90
     * @throws \Pizdata\OAuth2\Client\Exception\ShopifyIdentityProviderException
91
     * @param  ResponseInterface $response
92
     * @param  array $data
93
     * @return void
94
     */
95 12
    protected function checkResponse(ResponseInterface $response, $data)
96
    {
97 12
        if ($response->getStatusCode() == 400) {
98 3
            throw new ShopifyIdentityProviderException($data, 0, $response->getReasonPhrase());
0 ignored issues
show
Documentation introduced by
$data is of type array, but the function expects a 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...
99
        }
100
101 9
        if (!empty($data['errors'])) {
102 3
            throw new ShopifyIdentityProviderException($data['errors'], 0, $data);
103
        }
104 6
    }
105
106
    /**
107
     * Generate a user object from a successful user details request.
108
     *
109
     * @param array $response
110
     * @param AccessToken $token
111
     * @return League\OAuth2\Client\Provider\ResourceOwnerInterface
112
     */
113 3
    protected function createResourceOwner(array $response, AccessToken $token)
114
    {
115 3
        $store = new ShopifyResourceOwner($response);
116
117 3
        return $store;
118
    }
119
}
120