@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * @method \Psr\Http\Message\ResponseInterface me() |
| 24 | 24 | */ |
| 25 | -class Foursquare extends OAuth2Provider{ |
|
| 25 | +class Foursquare extends OAuth2Provider { |
|
| 26 | 26 | |
| 27 | 27 | protected const API_VERSIONDATE = '20190225'; |
| 28 | 28 | |
@@ -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 = $this->parseQuery(QueryUtil::parseUrl($this->apiURL.$path)['query'] ?? ''); |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | * @method \Psr\Http\Message\ResponseInterface wvwUpgrades(array $params = ['lang']) |
| 238 | 238 | * @method \Psr\Http\Message\ResponseInterface wvwUpgradesId(string $id, array $params = ['lang']) |
| 239 | 239 | */ |
| 240 | -class GuildWars2 extends OAuth2Provider{ |
|
| 240 | +class GuildWars2 extends OAuth2Provider { |
|
| 241 | 241 | |
| 242 | 242 | public const SCOPE_ACCOUNT = 'account'; |
| 243 | 243 | public const SCOPE_INVENTORIES = 'inventories'; |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | */ |
| 268 | 268 | public function storeGW2Token(string $access_token):AccessToken{ |
| 269 | 269 | |
| 270 | - if(!preg_match('/^[a-f\d\-]{72}$/i', $access_token)){ |
|
| 270 | + if (!preg_match('/^[a-f\d\-]{72}$/i', $access_token)) { |
|
| 271 | 271 | throw new ProviderException('invalid token'); |
| 272 | 272 | } |
| 273 | 273 | |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | |
| 278 | 278 | $tokeninfo = MessageUtil::decodeJSON($this->http->sendRequest($request)); |
| 279 | 279 | |
| 280 | - if(isset($tokeninfo->id) && str_starts_with($access_token, $tokeninfo->id)){ |
|
| 280 | + if (isset($tokeninfo->id) && str_starts_with($access_token, $tokeninfo->id)) { |
|
| 281 | 281 | |
| 282 | 282 | $token = new AccessToken; |
| 283 | 283 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @method \Psr\Http\Message\ResponseInterface userGetWeeklyChartList(array $params = ['user']) |
| 75 | 75 | * @method \Psr\Http\Message\ResponseInterface userGetWeeklyTrackChart(array $params = ['from', 'to', 'user']) |
| 76 | 76 | */ |
| 77 | -class LastFM extends OAuthProvider{ |
|
| 77 | +class LastFM extends OAuthProvider { |
|
| 78 | 78 | |
| 79 | 79 | public const PERIOD_OVERALL = 'overall'; |
| 80 | 80 | public const PERIOD_7DAY = '7day'; |
@@ -121,8 +121,8 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | $signature = ''; |
| 123 | 123 | |
| 124 | - foreach($params as $k => $v){ |
|
| 125 | - if(!in_array($k, ['format', 'callback'])){ |
|
| 124 | + foreach ($params as $k => $v) { |
|
| 125 | + if (!in_array($k, ['format', 'callback'])) { |
|
| 126 | 126 | $signature .= $k.$v; |
| 127 | 127 | } |
| 128 | 128 | } |
@@ -160,21 +160,21 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | protected function parseTokenResponse(ResponseInterface $response):AccessToken{ |
| 162 | 162 | |
| 163 | - try{ |
|
| 163 | + try { |
|
| 164 | 164 | $data = MessageUtil::decodeJSON($response, true); |
| 165 | 165 | |
| 166 | - if(!$data || !is_array($data)){ |
|
| 166 | + if (!$data || !is_array($data)) { |
|
| 167 | 167 | trigger_error(''); |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | - catch(Throwable $e){ |
|
| 170 | + catch (Throwable $e) { |
|
| 171 | 171 | throw new ProviderException('unable to parse token response'); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - if(isset($data['error'])){ |
|
| 174 | + if (isset($data['error'])) { |
|
| 175 | 175 | throw new ProviderException('error retrieving access token: '.$data['message']); |
| 176 | 176 | } |
| 177 | - elseif(!isset($data['session']['key'])){ |
|
| 177 | + elseif (!isset($data['session']['key'])) { |
|
| 178 | 178 | throw new ProviderException('token missing'); |
| 179 | 179 | } |
| 180 | 180 | |
@@ -200,11 +200,11 @@ discard block |
||
| 200 | 200 | string $path, |
| 201 | 201 | array $params = null, |
| 202 | 202 | string $method = null, |
| 203 | - StreamInterface|array|string $body = null, |
|
| 203 | + StreamInterface | array | string $body = null, |
|
| 204 | 204 | array $headers = null |
| 205 | 205 | ):ResponseInterface{ |
| 206 | 206 | |
| 207 | - if($body !== null && !is_array($body)){ |
|
| 207 | + if ($body !== null && !is_array($body)) { |
|
| 208 | 208 | throw new ProviderException('$body must be an array'); |
| 209 | 209 | } |
| 210 | 210 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | |
| 222 | 222 | $params['api_sig'] = $this->getSignature($params); |
| 223 | 223 | |
| 224 | - if($method === 'POST'){ |
|
| 224 | + if ($method === 'POST') { |
|
| 225 | 225 | $body = $params; |
| 226 | 226 | $params = []; |
| 227 | 227 | } |
@@ -229,11 +229,11 @@ discard block |
||
| 229 | 229 | /** @phan-suppress-next-line PhanTypeMismatchArgumentNullable */ |
| 230 | 230 | $request = $this->requestFactory->createRequest($method, $this->mergeQuery($this->apiURL, $params)); |
| 231 | 231 | |
| 232 | - foreach(array_merge($this->apiHeaders, $headers ?? []) as $header => $value){ |
|
| 232 | + foreach (array_merge($this->apiHeaders, $headers ?? []) as $header => $value) { |
|
| 233 | 233 | $request = $request->withAddedHeader($header, $value); |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - if($method === 'POST'){ |
|
| 236 | + if ($method === 'POST') { |
|
| 237 | 237 | $request = $request->withHeader('Content-Type', 'application/x-www-form-urlencoded'); |
| 238 | 238 | $body = $this->streamFactory->createStream($this->buildQuery($body, PHP_QUERY_RFC1738)); |
| 239 | 239 | $request = $request->withBody($body); |
@@ -166,15 +166,13 @@ |
||
| 166 | 166 | if(!$data || !is_array($data)){ |
| 167 | 167 | trigger_error(''); |
| 168 | 168 | } |
| 169 | - } |
|
| 170 | - catch(Throwable $e){ |
|
| 169 | + } catch(Throwable $e){ |
|
| 171 | 170 | throw new ProviderException('unable to parse token response'); |
| 172 | 171 | } |
| 173 | 172 | |
| 174 | 173 | if(isset($data['error'])){ |
| 175 | 174 | throw new ProviderException('error retrieving access token: '.$data['message']); |
| 176 | - } |
|
| 177 | - elseif(!isset($data['session']['key'])){ |
|
| 175 | + } elseif(!isset($data['session']['key'])){ |
|
| 178 | 176 | throw new ProviderException('token missing'); |
| 179 | 177 | } |
| 180 | 178 | |
@@ -52,21 +52,21 @@ discard block |
||
| 52 | 52 | protected function parseTokenResponse(ResponseInterface $response):AccessToken{ |
| 53 | 53 | $data = json_decode(MessageUtil::decompress($response), true); |
| 54 | 54 | |
| 55 | - if(!is_array($data)){ |
|
| 55 | + if (!is_array($data)) { |
|
| 56 | 56 | throw new ProviderException('unable to parse token response'); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - foreach(['error_description', 'error'] as $field){ |
|
| 60 | - if(isset($data[$field])){ |
|
| 59 | + foreach (['error_description', 'error'] as $field) { |
|
| 60 | + if (isset($data[$field])) { |
|
| 61 | 61 | throw new ProviderException('error retrieving access token: "'.$data[$field].'"'); |
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // @codeCoverageIgnoreStart |
| 66 | - if(isset($data['name'], $data['message'])){ |
|
| 66 | + if (isset($data['name'], $data['message'])) { |
|
| 67 | 67 | $msg = sprintf('error retrieving access token: "%s" [%s]', $data['message'], $data['name']); |
| 68 | 68 | |
| 69 | - if(isset($data['links']) && is_array($data['links'])){ |
|
| 69 | + if (isset($data['links']) && is_array($data['links'])) { |
|
| 70 | 70 | $msg .= "\n".implode("\n", array_column($data['links'], 'href')); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | // @codeCoverageIgnoreEnd |
| 76 | 76 | |
| 77 | - if(!isset($data['access_token'])){ |
|
| 77 | + if (!isset($data['access_token'])) { |
|
| 78 | 78 | throw new ProviderException('token missing'); |
| 79 | 79 | } |
| 80 | 80 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * |
| 18 | 18 | * Note: the endpoints are ordered by the api docs (against any logical pattern) |
| 19 | 19 | */ |
| 20 | -class TwitterCCEndpoints extends EndpointMap{ |
|
| 20 | +class TwitterCCEndpoints extends EndpointMap { |
|
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * 2.4 Follow, search, and get users |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | protected array $friendshipsShow = [ |
| 80 | 80 | 'path' => '/1.1/friendships/show.json', |
| 81 | 81 | 'method' => 'GET', |
| 82 | - 'query' => ['source_id', 'source_screen_name', 'target_id', 'target_screen_name',], |
|
| 82 | + 'query' => ['source_id', 'source_screen_name', 'target_id', 'target_screen_name', ], |
|
| 83 | 83 | 'path_elements' => null, |
| 84 | 84 | 'body' => null, |
| 85 | 85 | 'headers' => null, |
@@ -62,15 +62,15 @@ discard block |
||
| 62 | 62 | protected function getRequestTarget(string $uri):string{ |
| 63 | 63 | $parsedURL = QueryUtil::parseUrl($uri); |
| 64 | 64 | |
| 65 | - if(!isset($parsedURL['path'])){ |
|
| 65 | + if (!isset($parsedURL['path'])) { |
|
| 66 | 66 | throw new ProviderException('invalid path'); // @codeCoverageIgnore |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // for some reason we were given a host name |
| 70 | - if(isset($parsedURL['host'])){ |
|
| 70 | + if (isset($parsedURL['host'])) { |
|
| 71 | 71 | |
| 72 | 72 | // back out if it doesn't match |
| 73 | - if(!str_contains($parsedURL['host'], '.api.npr.org')){ |
|
| 73 | + if (!str_contains($parsedURL['host'], '.api.npr.org')) { |
|
| 74 | 74 | throw new ProviderException('given host does not match provider host'); // @codeCoverageIgnore |
| 75 | 75 | } |
| 76 | 76 | |
@@ -88,14 +88,14 @@ discard block |
||
| 88 | 88 | public function sendRequest(RequestInterface $request):ResponseInterface{ |
| 89 | 89 | |
| 90 | 90 | // get authorization only if we request the provider API |
| 91 | - if(str_contains((string)$request->getUri(), '.api.npr.org')){ |
|
| 91 | + if (str_contains((string)$request->getUri(), '.api.npr.org')) { |
|
| 92 | 92 | $token = $this->storage->getAccessToken($this->serviceName); |
| 93 | 93 | |
| 94 | 94 | // attempt to refresh an expired token |
| 95 | - if( |
|
| 95 | + if ( |
|
| 96 | 96 | $this->options->tokenAutoRefresh |
| 97 | 97 | && ($token->isExpired() || $token->expires === $token::EOL_UNKNOWN) |
| 98 | - ){ |
|
| 98 | + ) { |
|
| 99 | 99 | $token = $this->refreshAccessToken($token); // @codeCoverageIgnore |
| 100 | 100 | } |
| 101 | 101 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | /** |
| 27 | 27 | * @method \Psr\Http\Message\ResponseInterface me() |
| 28 | 28 | */ |
| 29 | -class Deezer extends OAuth2Provider implements CSRFToken{ |
|
| 29 | +class Deezer extends OAuth2Provider implements CSRFToken { |
|
| 30 | 30 | |
| 31 | 31 | public const SCOPE_BASIC = 'basic_access'; |
| 32 | 32 | public const SCOPE_EMAIL = 'email'; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | public function getAuthURL(array $params = null, array $scopes = null):UriInterface{ |
| 60 | 60 | $params ??= []; |
| 61 | 61 | |
| 62 | - if(isset($params['client_secret'])){ |
|
| 62 | + if (isset($params['client_secret'])) { |
|
| 63 | 63 | unset($params['client_secret']); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -107,11 +107,11 @@ discard block |
||
| 107 | 107 | protected function parseTokenResponse(ResponseInterface $response):AccessToken{ |
| 108 | 108 | $data = $this->parseQuery(MessageUtil::decompress($response)); |
| 109 | 109 | |
| 110 | - if(isset($data['error_reason'])){ |
|
| 110 | + if (isset($data['error_reason'])) { |
|
| 111 | 111 | throw new ProviderException('error retrieving access token: "'.$data['error_reason'].'"'); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if(!isset($data['access_token'])){ |
|
| 114 | + if (!isset($data['access_token'])) { |
|
| 115 | 115 | throw new ProviderException('token missing'); |
| 116 | 116 | } |
| 117 | 117 | |
@@ -122,7 +122,7 @@ |
||
| 122 | 122 | public function setInstance(string $instance):Mastodon{ |
| 123 | 123 | $instance = QueryUtil::parseUrl($instance); |
| 124 | 124 | |
| 125 | - if(!isset($instance['host'])){ |
|
| 125 | + if (!isset($instance['host'])) { |
|
| 126 | 126 | throw new OAuthException('invalid instance URL'); |
| 127 | 127 | } |
| 128 | 128 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * @method \Psr\Http\Message\ResponseInterface ping() |
| 28 | 28 | * @method \Psr\Http\Message\ResponseInterface root(array $params = ['fields', 'exclude_fields']) |
| 29 | 29 | */ |
| 30 | -class MailChimp extends OAuth2Provider implements CSRFToken{ |
|
| 30 | +class MailChimp extends OAuth2Provider implements CSRFToken { |
|
| 31 | 31 | |
| 32 | 32 | protected const API_BASE = 'https://%s.api.mailchimp.com/3.0'; |
| 33 | 33 | protected const METADATA_ENDPOINT = 'https://login.mailchimp.com/oauth2/metadata'; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | $token ??= $this->storage->getAccessToken($this->serviceName); |
| 51 | 51 | |
| 52 | - if(!$token instanceof AccessToken){ |
|
| 52 | + if (!$token instanceof AccessToken) { |
|
| 53 | 53 | throw new OAuthException('invalid token'); // @codeCoverageIgnore |
| 54 | 54 | } |
| 55 | 55 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | $response = $this->http->sendRequest($request); |
| 62 | 62 | |
| 63 | - if($response->getStatusCode() !== 200){ |
|
| 63 | + if ($response->getStatusCode() !== 200) { |
|
| 64 | 64 | throw new OAuthException('metadata response error'); // @codeCoverageIgnore |
| 65 | 65 | } |
| 66 | 66 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | string $path, |
| 81 | 81 | array $params = null, |
| 82 | 82 | string $method = null, |
| 83 | - StreamInterface|array|string $body = null, |
|
| 83 | + StreamInterface | array | string $body = null, |
|
| 84 | 84 | array $headers = null |
| 85 | 85 | ):ResponseInterface{ |
| 86 | 86 | $token = $this->storage->getAccessToken($this->serviceName); |