@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @see https://developer.foursquare.com/docs/ |
24 | 24 | * @see https://developer.foursquare.com/overview/auth |
25 | 25 | */ |
26 | -class Foursquare extends OAuth2Provider{ |
|
26 | +class Foursquare extends OAuth2Provider { |
|
27 | 27 | |
28 | 28 | protected const API_VERSIONDATE = '20190225'; |
29 | 29 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | string $path, |
44 | 44 | array $params = null, |
45 | 45 | string $method = null, |
46 | - StreamInterface|array|string $body = null, |
|
46 | + StreamInterface | array | string $body = null, |
|
47 | 47 | array $headers = null |
48 | 48 | ):ResponseInterface{ |
49 | 49 | $queryparams = QueryUtil::parse(QueryUtil::parseUrl($this->apiURL.$path)['query'] ?? ''); |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | $response = $this->request('/v2/users/self'); |
61 | 61 | $status = $response->getStatusCode(); |
62 | 62 | |
63 | - if($status === 200){ |
|
63 | + if ($status === 200) { |
|
64 | 64 | return $response; |
65 | 65 | } |
66 | 66 | |
67 | 67 | $json = MessageUtil::decodeJSON($response); |
68 | 68 | |
69 | - if(isset($json->meta, $json->meta->errorDetail)){ |
|
69 | + if (isset($json->meta, $json->meta->errorDetail)) { |
|
70 | 70 | throw new ProviderException($json->meta->errorDetail); |
71 | 71 | } |
72 | 72 |
@@ -46,13 +46,13 @@ |
||
46 | 46 | $response = $this->request('/accounts'); |
47 | 47 | $status = $response->getStatusCode(); |
48 | 48 | |
49 | - if($status === 200){ |
|
49 | + if ($status === 200) { |
|
50 | 50 | return $response; |
51 | 51 | } |
52 | 52 | |
53 | 53 | $json = MessageUtil::decodeJSON($response); |
54 | 54 | |
55 | - if(isset($json->error, $json->error_description)){ |
|
55 | + if (isset($json->error, $json->error_description)) { |
|
56 | 56 | throw new ProviderException($json->error_description); |
57 | 57 | } |
58 | 58 |
@@ -47,13 +47,13 @@ |
||
47 | 47 | $response = $this->request('/user/profile'); |
48 | 48 | $status = $response->getStatusCode(); |
49 | 49 | |
50 | - if($status === 200){ |
|
50 | + if ($status === 200) { |
|
51 | 51 | return $response; |
52 | 52 | } |
53 | 53 | |
54 | 54 | $json = MessageUtil::decodeJSON($response); |
55 | 55 | |
56 | - if(isset($json->error, $json->error_description)){ |
|
56 | + if (isset($json->error, $json->error_description)) { |
|
57 | 57 | throw new ProviderException($json->error_description); |
58 | 58 | } |
59 | 59 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @see https://api.guildwars2.com/v2 |
28 | 28 | * @see https://wiki.guildwars2.com/wiki/API:Main |
29 | 29 | */ |
30 | -class GuildWars2 extends OAuth2Provider{ |
|
30 | +class GuildWars2 extends OAuth2Provider { |
|
31 | 31 | |
32 | 32 | public const SCOPE_ACCOUNT = 'account'; |
33 | 33 | public const SCOPE_INVENTORIES = 'inventories'; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function storeGW2Token(string $access_token):AccessToken{ |
58 | 58 | |
59 | - if(!preg_match('/^[a-f\d\-]{72}$/i', $access_token)){ |
|
59 | + if (!preg_match('/^[a-f\d\-]{72}$/i', $access_token)) { |
|
60 | 60 | throw new ProviderException('invalid token'); |
61 | 61 | } |
62 | 62 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | $tokeninfo = MessageUtil::decodeJSON($this->http->sendRequest($request)); |
69 | 69 | |
70 | - if(isset($tokeninfo->id) && str_starts_with($access_token, $tokeninfo->id)){ |
|
70 | + if (isset($tokeninfo->id) && str_starts_with($access_token, $tokeninfo->id)) { |
|
71 | 71 | $token = new AccessToken; |
72 | 72 | $token->provider = $this->serviceName; |
73 | 73 | $token->accessToken = $access_token; |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | $response = $this->request('/v2/tokeninfo'); |
112 | 112 | $status = $response->getStatusCode(); |
113 | 113 | |
114 | - if($status === 200){ |
|
114 | + if ($status === 200) { |
|
115 | 115 | return $response; |
116 | 116 | } |
117 | 117 | |
118 | 118 | $json = MessageUtil::decodeJSON($response); |
119 | 119 | |
120 | - if(isset($json->text)){ |
|
120 | + if (isset($json->text)) { |
|
121 | 121 | throw new ProviderException($json->text); |
122 | 122 | } |
123 | 123 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * @see https://www.last.fm/api/authentication |
29 | 29 | */ |
30 | -class LastFM extends OAuthProvider{ |
|
30 | +class LastFM extends OAuthProvider { |
|
31 | 31 | |
32 | 32 | public const PERIOD_OVERALL = 'overall'; |
33 | 33 | public const PERIOD_7DAY = '7day'; |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | |
71 | 71 | $signature = ''; |
72 | 72 | |
73 | - foreach($params as $k => $v){ |
|
74 | - if(!in_array($k, ['format', 'callback'])){ |
|
73 | + foreach ($params as $k => $v) { |
|
74 | + if (!in_array($k, ['format', 'callback'])) { |
|
75 | 75 | $signature .= $k.$v; |
76 | 76 | } |
77 | 77 | } |
@@ -104,21 +104,21 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function parseTokenResponse(ResponseInterface $response):AccessToken{ |
106 | 106 | |
107 | - try{ |
|
107 | + try { |
|
108 | 108 | $data = MessageUtil::decodeJSON($response, true); |
109 | 109 | |
110 | - if(!$data || !is_array($data)){ |
|
110 | + if (!$data || !is_array($data)) { |
|
111 | 111 | trigger_error(''); |
112 | 112 | } |
113 | 113 | } |
114 | - catch(Throwable $e){ |
|
114 | + catch (Throwable $e) { |
|
115 | 115 | throw new ProviderException('unable to parse token response'); |
116 | 116 | } |
117 | 117 | |
118 | - if(isset($data['error'])){ |
|
118 | + if (isset($data['error'])) { |
|
119 | 119 | throw new ProviderException('error retrieving access token: '.$data['message']); |
120 | 120 | } |
121 | - elseif(!isset($data['session']['key'])){ |
|
121 | + elseif (!isset($data['session']['key'])) { |
|
122 | 122 | throw new ProviderException('token missing'); |
123 | 123 | } |
124 | 124 | |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | string $path, |
145 | 145 | array $params = null, |
146 | 146 | string $method = null, |
147 | - StreamInterface|array|string $body = null, |
|
147 | + StreamInterface | array | string $body = null, |
|
148 | 148 | array $headers = null |
149 | 149 | ):ResponseInterface{ |
150 | 150 | |
151 | - if($body !== null && !is_array($body)){ |
|
151 | + if ($body !== null && !is_array($body)) { |
|
152 | 152 | throw new ProviderException('$body must be an array'); |
153 | 153 | } |
154 | 154 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | $params['api_sig'] = $this->getSignature($params); |
167 | 167 | |
168 | - if($method === 'POST'){ |
|
168 | + if ($method === 'POST') { |
|
169 | 169 | $body = $params; |
170 | 170 | $params = []; |
171 | 171 | } |
@@ -173,11 +173,11 @@ discard block |
||
173 | 173 | /** @phan-suppress-next-line PhanTypeMismatchArgumentNullable */ |
174 | 174 | $request = $this->requestFactory->createRequest($method, QueryUtil::merge($this->apiURL, $params)); |
175 | 175 | |
176 | - foreach(array_merge($this->apiHeaders, $headers ?? []) as $header => $value){ |
|
176 | + foreach (array_merge($this->apiHeaders, $headers ?? []) as $header => $value) { |
|
177 | 177 | $request = $request->withAddedHeader($header, $value); |
178 | 178 | } |
179 | 179 | |
180 | - if($method === 'POST'){ |
|
180 | + if ($method === 'POST') { |
|
181 | 181 | $request = $request->withHeader('Content-Type', 'application/x-www-form-urlencoded'); |
182 | 182 | $body = $this->streamFactory->createStream(QueryUtil::build($body, PHP_QUERY_RFC1738)); |
183 | 183 | $request = $request->withBody($body); |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | $response = $this->request('user.getInfo'); |
202 | 202 | $status = $response->getStatusCode(); |
203 | 203 | |
204 | - if($status === 200){ |
|
204 | + if ($status === 200) { |
|
205 | 205 | return $response; |
206 | 206 | } |
207 | 207 | |
208 | 208 | $json = MessageUtil::decodeJSON($response); |
209 | 209 | |
210 | - if(isset($json->error, $json->error_description)){ |
|
210 | + if (isset($json->error, $json->error_description)) { |
|
211 | 211 | throw new ProviderException($json->error_description); |
212 | 212 | } |
213 | 213 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | /** |
20 | 20 | * @see https://www.opencaching.de/okapi/ |
21 | 21 | */ |
22 | -class OpenCaching extends OAuth1Provider{ |
|
22 | +class OpenCaching extends OAuth1Provider { |
|
23 | 23 | |
24 | 24 | protected string $requestTokenURL = 'https://www.opencaching.de/okapi/services/oauth/request_token'; |
25 | 25 | protected string $authURL = 'https://www.opencaching.de/okapi/services/oauth/authorize'; |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | $response = $this->request('/users/user', ['fields' => 'uuid|username|profile_url|internal_id|date_registered|caches_found|caches_notfound|caches_hidden|rcmds_given|rcmds_left|rcmd_founds_needed|home_location']); |
37 | 37 | $status = $response->getStatusCode(); |
38 | 38 | |
39 | - if($status === 200){ |
|
39 | + if ($status === 200) { |
|
40 | 40 | return $response; |
41 | 41 | } |
42 | 42 | |
43 | 43 | $json = MessageUtil::decodeJSON($response); |
44 | 44 | |
45 | - if(isset($json->error, $json->error_description)){ |
|
45 | + if (isset($json->error, $json->error_description)) { |
|
46 | 46 | throw new ProviderException($json->error_description); |
47 | 47 | } |
48 | 48 |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | protected array $authHeaders = ['Accept' => 'application/vnd.twitchtv.v5+json']; |
59 | 59 | protected array $apiHeaders = ['Accept' => 'application/vnd.twitchtv.v5+json']; |
60 | 60 | |
61 | - protected array $defaultScopes = [ |
|
61 | + protected array $defaultScopes = [ |
|
62 | 62 | self::SCOPE_USER_READ_EMAIL, |
63 | 63 | ]; |
64 | 64 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | 'grant_type' => 'client_credentials', |
73 | 73 | ]; |
74 | 74 | |
75 | - if($scopes !== null){ |
|
75 | + if ($scopes !== null) { |
|
76 | 76 | $params['scope'] = implode($this->scopesDelimiter, $scopes); |
77 | 77 | } |
78 | 78 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | ->withBody($this->streamFactory->createStream(QueryUtil::build($params, PHP_QUERY_RFC1738))) |
83 | 83 | ; |
84 | 84 | |
85 | - foreach($this->authHeaders as $header => $value){ |
|
85 | + foreach ($this->authHeaders as $header => $value) { |
|
86 | 86 | $request = $request->withAddedHeader($header, $value); |
87 | 87 | } |
88 | 88 | |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | $response = $this->request('/helix/users'); |
110 | 110 | $status = $response->getStatusCode(); |
111 | 111 | |
112 | - if($status === 200){ |
|
112 | + if ($status === 200) { |
|
113 | 113 | return $response; |
114 | 114 | } |
115 | 115 | |
116 | 116 | $json = MessageUtil::decodeJSON($response); |
117 | 117 | |
118 | - if(isset($json->error, $json->message)){ |
|
118 | + if (isset($json->error, $json->message)) { |
|
119 | 119 | throw new ProviderException($json->message); |
120 | 120 | } |
121 | 121 |
@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * @see https://developer.twitter.com/en/docs/basics/authentication/overview/oauth |
22 | 22 | */ |
23 | -class Twitter extends OAuth1Provider{ |
|
23 | +class Twitter extends OAuth1Provider { |
|
24 | 24 | |
25 | 25 | // choose your fighter |
26 | 26 | /** @see https://developer.twitter.com/en/docs/basics/authentication/api-reference/authorize */ |
27 | - protected string $authURL = 'https://api.twitter.com/oauth/authorize'; |
|
27 | + protected string $authURL = 'https://api.twitter.com/oauth/authorize'; |
|
28 | 28 | /** @see https://developer.twitter.com/en/docs/basics/authentication/api-reference/authenticate */ |
29 | 29 | # protected string $authURL = 'https://api.twitter.com/oauth/authenticate'; |
30 | 30 | |
@@ -42,13 +42,13 @@ discard block |
||
42 | 42 | $response = $this->request('/1.1/account/verify_credentials.json'); |
43 | 43 | $status = $response->getStatusCode(); |
44 | 44 | |
45 | - if($status === 200){ |
|
45 | + if ($status === 200) { |
|
46 | 46 | return $response; |
47 | 47 | } |
48 | 48 | |
49 | 49 | $json = MessageUtil::decodeJSON($response); |
50 | 50 | |
51 | - if(isset($json->errors, $json->errors[0]->message)){ |
|
51 | + if (isset($json->errors, $json->errors[0]->message)) { |
|
52 | 52 | throw new ProviderException($json->errors[0]->message); |
53 | 53 | } |
54 | 54 |
@@ -50,19 +50,19 @@ discard block |
||
50 | 50 | protected function parseTokenResponse(ResponseInterface $response):AccessToken{ |
51 | 51 | $data = json_decode(MessageUtil::decompress($response), true); |
52 | 52 | |
53 | - if(!is_array($data)){ |
|
53 | + if (!is_array($data)) { |
|
54 | 54 | throw new ProviderException('unable to parse token response'); |
55 | 55 | } |
56 | 56 | |
57 | - if(isset($data['error'])){ |
|
58 | - throw new ProviderException(sprintf('error retrieving access token: "%s"', $data['error'])); |
|
57 | + if (isset($data['error'])) { |
|
58 | + throw new ProviderException(sprintf('error retrieving access token: "%s"', $data['error'])); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | // @codeCoverageIgnoreStart |
62 | - if(isset($data['name'], $data['message'])){ |
|
62 | + if (isset($data['name'], $data['message'])) { |
|
63 | 63 | $msg = sprintf('error retrieving access token: "%s" [%s]', $data['message'], $data['name']); |
64 | 64 | |
65 | - if(isset($data['links']) && is_array($data['links'])){ |
|
65 | + if (isset($data['links']) && is_array($data['links'])) { |
|
66 | 66 | $msg .= "\n".implode("\n", array_column($data['links'], 'href')); |
67 | 67 | } |
68 | 68 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | } |
71 | 71 | // @codeCoverageIgnoreEnd |
72 | 72 | |
73 | - if(!isset($data['access_token'])){ |
|
73 | + if (!isset($data['access_token'])) { |
|
74 | 74 | throw new ProviderException('token missing'); |
75 | 75 | } |
76 | 76 | |
@@ -121,13 +121,13 @@ discard block |
||
121 | 121 | $response = $this->request('/v1/identity/oauth2/userinfo', ['schema' => 'paypalv1.1']); |
122 | 122 | $status = $response->getStatusCode(); |
123 | 123 | |
124 | - if($status === 200){ |
|
124 | + if ($status === 200) { |
|
125 | 125 | return $response; |
126 | 126 | } |
127 | 127 | |
128 | 128 | $json = MessageUtil::decodeJSON($response); |
129 | 129 | |
130 | - if(isset($json->error, $json->error_description)){ |
|
130 | + if (isset($json->error, $json->error_description)) { |
|
131 | 131 | throw new ProviderException($json->error_description); |
132 | 132 | } |
133 | 133 |