1 | <?php namespace Pizdata\OAuth2\Client\Provider; |
||
8 | class Shopify extends AbstractProvider |
||
9 | { |
||
10 | /** |
||
11 | * Production Shopify domain. |
||
12 | * |
||
13 | * @const string |
||
14 | */ |
||
15 | const BASE_SHOPIFY_DOMAIN = 'myshopify.com'; |
||
16 | |||
17 | /** |
||
18 | * The store name. |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | public $store = ''; |
||
23 | |||
24 | /** |
||
25 | * @param array $options |
||
26 | * @param array $collaborators |
||
27 | * |
||
28 | * @throws \InvalidArgumentException |
||
29 | */ |
||
30 | 6 | public function __construct($options = [], array $collaborators = []) |
|
31 | { |
||
32 | 6 | parent::__construct($options, $collaborators); |
|
33 | |||
34 | 6 | if (empty($options['store'])) { |
|
35 | 3 | $message = 'The "store" option not set. Please set a Store name.'; |
|
36 | 3 | throw new \InvalidArgumentException($message); |
|
37 | } |
||
38 | |||
39 | 6 | $this->store = $options['store']; |
|
40 | 6 | } |
|
41 | |||
42 | /** |
||
43 | * Get authorization url to begin OAuth flow |
||
44 | * |
||
45 | * @return string |
||
46 | */ |
||
47 | 3 | public function getBaseAuthorizationUrl() |
|
51 | |||
52 | /** |
||
53 | * Get access token url to retrieve token |
||
54 | * |
||
55 | * @param array $params |
||
56 | * |
||
57 | * @return string |
||
58 | */ |
||
59 | 6 | public function getBaseAccessTokenUrl(array $params) |
|
63 | |||
64 | /** |
||
65 | * Get provider url to fetch user details |
||
66 | * |
||
67 | * @param AccessToken $token |
||
68 | * |
||
69 | * @return string |
||
70 | */ |
||
71 | 6 | public function getResourceOwnerDetailsUrl(AccessToken $token) |
|
72 | { |
||
73 | 6 | return sprintf( |
|
74 | 6 | 'https://%s.%s/admin/shop.json?access_token=%s', |
|
75 | 6 | $this->store, |
|
76 | 6 | self::BASE_SHOPIFY_DOMAIN, |
|
77 | 6 | $token->getToken() |
|
78 | 4 | ); |
|
79 | } |
||
80 | |||
81 | /** |
||
82 | * Get the default scopes used by this provider. |
||
83 | * |
||
84 | * @link https://help.shopify.com/api/getting-started/authentication/oauth#scopes |
||
85 | * @return array |
||
86 | */ |
||
87 | 3 | protected function getDefaultScopes() |
|
94 | |||
95 | /** |
||
96 | * Check a provider response for errors. |
||
97 | * |
||
98 | * @throws \Pizdata\OAuth2\Client\Exception\ShopifyIdentityProviderException |
||
99 | * @param ResponseInterface $response |
||
100 | * @param array $data |
||
101 | * @return void |
||
102 | */ |
||
103 | 12 | protected function checkResponse(ResponseInterface $response, $data) |
|
114 | |||
115 | /** |
||
116 | * Generate a user object from a successful user details request. |
||
117 | * |
||
118 | * @param array $response |
||
119 | * @param AccessToken $token |
||
120 | * @return League\OAuth2\Client\Provider\ResourceOwnerInterface |
||
121 | */ |
||
122 | 3 | protected function createResourceOwner(array $response, AccessToken $token) |
|
128 | } |
||
129 |
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: