@@ -43,7 +43,7 @@ |
||
43 | 43 | * @method \Psr\Http\Message\ResponseInterface tags(string $tagname) |
44 | 44 | * @method \Psr\Http\Message\ResponseInterface tagsRecentMedia(string $tagname, array $params = ['max_tag_id', 'min_tag_id', 'count']) |
45 | 45 | */ |
46 | -class Instagram extends OAuth2Provider implements CSRFToken{ |
|
46 | +class Instagram extends OAuth2Provider implements CSRFToken { |
|
47 | 47 | |
48 | 48 | public const SCOPE_BASIC = 'basic'; |
49 | 49 | public const SCOPE_COMMENTS = 'comments'; |
@@ -21,7 +21,7 @@ |
||
21 | 21 | * @method \Psr\Http\Message\ResponseInterface getUser(string $username) |
22 | 22 | * @method \Psr\Http\Message\ResponseInterface me() |
23 | 23 | */ |
24 | -class GitHub extends OAuth2Provider implements CSRFToken{ |
|
24 | +class GitHub extends OAuth2Provider implements CSRFToken { |
|
25 | 25 | |
26 | 26 | const SCOPE_USER = 'user'; |
27 | 27 | const SCOPE_USER_EMAIL = 'user:email'; |
@@ -243,7 +243,7 @@ |
||
243 | 243 | * @method \Psr\Http\Message\ResponseInterface urlsLookupGroup(array $params = ['url']) |
244 | 244 | * @method \Psr\Http\Message\ResponseInterface urlsLookupUser(array $params = ['url']) |
245 | 245 | */ |
246 | -class Flickr extends OAuth1Provider{ |
|
246 | +class Flickr extends OAuth1Provider { |
|
247 | 247 | |
248 | 248 | public const PERM_READ = 'read'; |
249 | 249 | public const PERM_WRITE = 'write'; |
@@ -132,7 +132,7 @@ |
||
132 | 132 | * @method \Psr\Http\Message\ResponseInterface usersSuggestionsSlugMembers(string $slug, array $params = ['lang']) |
133 | 133 | * @method \Psr\Http\Message\ResponseInterface verifyCredentials(array $params = ['include_entities', 'skip_status']) |
134 | 134 | */ |
135 | -class TwitterCC extends OAuth2Provider implements ClientCredentials{ |
|
135 | +class TwitterCC extends OAuth2Provider implements ClientCredentials { |
|
136 | 136 | |
137 | 137 | protected const AUTH_ERRMSG = 'TwitterCC only supports Client Credentials Grant, use the Twitter OAuth1 class for authentication instead.'; |
138 | 138 |
@@ -17,7 +17,7 @@ |
||
17 | 17 | /** |
18 | 18 | * @method \Psr\Http\Message\ResponseInterface me() |
19 | 19 | */ |
20 | -class MicrosoftGraph extends AzureActiveDirectory{ |
|
20 | +class MicrosoftGraph extends AzureActiveDirectory { |
|
21 | 21 | |
22 | 22 | public const SCOPE_USER_READ = 'User.Read'; |
23 | 23 | public const SCOPE_USER_READBASIC_ALL = 'User.ReadBasic.All'; |
@@ -14,22 +14,22 @@ |
||
14 | 14 | |
15 | 15 | use function function_exists, hash, realpath, str_replace, strlen, substr; |
16 | 16 | |
17 | -if(!function_exists(__NAMESPACE__.'\\getProviders')){ |
|
17 | +if (!function_exists(__NAMESPACE__.'\\getProviders')) { |
|
18 | 18 | |
19 | 19 | function getProviders():array{ |
20 | 20 | $providers = []; |
21 | 21 | |
22 | 22 | /** @var \SplFileInfo $e */ |
23 | - foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__, FilesystemIterator::SKIP_DOTS)) as $e){ |
|
23 | + foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__, FilesystemIterator::SKIP_DOTS)) as $e) { |
|
24 | 24 | |
25 | - if($e->getExtension() !== 'php' || realpath($e->getPath()) === __DIR__){ |
|
25 | + if ($e->getExtension() !== 'php' || realpath($e->getPath()) === __DIR__) { |
|
26 | 26 | continue; |
27 | 27 | } |
28 | 28 | |
29 | 29 | $class = __NAMESPACE__.str_replace('/', '\\', substr($e->getPathname(), strlen(__DIR__), -4)); |
30 | 30 | $r = new ReflectionClass($class); |
31 | 31 | |
32 | - if(!$r->implementsInterface(OAuthInterface::class) || $r->isAbstract()){ |
|
32 | + if (!$r->implementsInterface(OAuthInterface::class) || $r->isAbstract()) { |
|
33 | 33 | continue; |
34 | 34 | } |
35 | 35 |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * @method \Psr\Http\Message\ResponseInterface wvwUpgrades(array $params = ['lang']) |
233 | 233 | * @method \Psr\Http\Message\ResponseInterface wvwUpgradesId(string $id, array $params = ['lang']) |
234 | 234 | */ |
235 | -class GuildWars2 extends OAuth2Provider{ |
|
235 | +class GuildWars2 extends OAuth2Provider { |
|
236 | 236 | |
237 | 237 | public const SCOPE_ACCOUNT = 'account'; |
238 | 238 | public const SCOPE_INVENTORIES = 'inventories'; |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public function storeGW2Token(string $access_token):AccessToken{ |
264 | 264 | |
265 | - if(!preg_match('/^[a-f\d\-]{72}$/i', $access_token)){ |
|
265 | + if (!preg_match('/^[a-f\d\-]{72}$/i', $access_token)) { |
|
266 | 266 | throw new ProviderException('invalid token'); |
267 | 267 | } |
268 | 268 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | |
273 | 273 | $tokeninfo = get_json($this->http->sendRequest($request)); |
274 | 274 | |
275 | - if(isset($tokeninfo->id) && \strpos($access_token, $tokeninfo->id) === 0){ |
|
275 | + if (isset($tokeninfo->id) && \strpos($access_token, $tokeninfo->id) === 0) { |
|
276 | 276 | |
277 | 277 | $token = new AccessToken([ |
278 | 278 | 'provider' => $this->serviceName, |
@@ -164,11 +164,9 @@ |
||
164 | 164 | |
165 | 165 | if(!$data || !is_array($data)){ |
166 | 166 | throw new ProviderException('unable to parse token response'); |
167 | - } |
|
168 | - elseif(isset($data['error'])){ |
|
167 | + } elseif(isset($data['error'])){ |
|
169 | 168 | throw new ProviderException('error retrieving access token: '.$data['message']); |
170 | - } |
|
171 | - elseif(!isset($data['session']['key'])){ |
|
169 | + } elseif(!isset($data['session']['key'])){ |
|
172 | 170 | throw new ProviderException('token missing'); |
173 | 171 | } |
174 | 172 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | use chillerlan\OAuth\Core\{AccessToken, OAuthProvider, ProviderException}; |
18 | 18 | use Psr\Http\Message\{RequestInterface, ResponseInterface, UriInterface}; |
19 | 19 | |
20 | -use function array_merge, http_build_query, in_array, is_array,ksort, md5; |
|
20 | +use function array_merge, http_build_query, in_array, is_array, ksort, md5; |
|
21 | 21 | use function chillerlan\HTTP\Psr7\{get_json, merge_query}; |
22 | 22 | |
23 | 23 | use const PHP_QUERY_RFC1738; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @method \Psr\Http\Message\ResponseInterface userGetWeeklyArtistChart(array $params = ['user', 'from', 'to']) |
77 | 77 | * @method \Psr\Http\Message\ResponseInterface userGetWeeklyTrackChart(array $params = ['user', 'from', 'to']) |
78 | 78 | */ |
79 | -class LastFM extends OAuthProvider{ |
|
79 | +class LastFM extends OAuthProvider { |
|
80 | 80 | |
81 | 81 | public const PERIOD_OVERALL = 'overall'; |
82 | 82 | public const PERIOD_7DAY = '7day'; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | self::PERIOD_12MONTH, |
95 | 95 | ]; |
96 | 96 | |
97 | - protected string $authURL = 'https://www.last.fm/api/auth'; |
|
97 | + protected string $authURL = 'https://www.last.fm/api/auth'; |
|
98 | 98 | protected ?string $apiURL = 'https://ws.audioscrobbler.com/2.0'; |
99 | 99 | protected ?string $userRevokeURL = 'https://www.last.fm/settings/applications'; |
100 | 100 | protected ?string $endpointMap = LastFMEndpoints::class; |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | |
124 | 124 | $signature = ''; |
125 | 125 | |
126 | - foreach($params as $k => $v){ |
|
127 | - if(!in_array($k, ['format', 'callback'])){ |
|
126 | + foreach ($params as $k => $v) { |
|
127 | + if (!in_array($k, ['format', 'callback'])) { |
|
128 | 128 | $signature .= $k.$v; |
129 | 129 | } |
130 | 130 | } |
@@ -163,13 +163,13 @@ discard block |
||
163 | 163 | protected function parseTokenResponse(ResponseInterface $response):AccessToken{ |
164 | 164 | $data = get_json($response, true); |
165 | 165 | |
166 | - if(!$data || !is_array($data)){ |
|
166 | + if (!$data || !is_array($data)) { |
|
167 | 167 | throw new ProviderException('unable to parse token response'); |
168 | 168 | } |
169 | - elseif(isset($data['error'])){ |
|
169 | + elseif (isset($data['error'])) { |
|
170 | 170 | throw new ProviderException('error retrieving access token: '.$data['message']); |
171 | 171 | } |
172 | - elseif(!isset($data['session']['key'])){ |
|
172 | + elseif (!isset($data['session']['key'])) { |
|
173 | 173 | throw new ProviderException('token missing'); |
174 | 174 | } |
175 | 175 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $method ??= 'GET'; |
223 | 223 | $params = $this->requestParams($path, $params ?? [], $body ?? []); |
224 | 224 | |
225 | - if($method === 'POST'){ |
|
225 | + if ($method === 'POST') { |
|
226 | 226 | $body = $params; |
227 | 227 | $params = []; |
228 | 228 | } |
@@ -230,11 +230,11 @@ discard block |
||
230 | 230 | /** @phan-suppress-next-line PhanTypeMismatchArgumentNullable */ |
231 | 231 | $request = $this->requestFactory->createRequest($method, merge_query($this->apiURL, $params)); |
232 | 232 | |
233 | - foreach(array_merge($this->apiHeaders, $headers ?? []) as $header => $value){ |
|
233 | + foreach (array_merge($this->apiHeaders, $headers ?? []) as $header => $value) { |
|
234 | 234 | $request = $request->withAddedHeader($header, $value); |
235 | 235 | } |
236 | 236 | |
237 | - if($method === 'POST'){ |
|
237 | + if ($method === 'POST') { |
|
238 | 238 | $request = $request->withHeader('Content-Type', 'application/x-www-form-urlencoded'); |
239 | 239 | $body = $this->streamFactory->createStream(http_build_query($body, '', '&', PHP_QUERY_RFC1738)); |
240 | 240 | $request = $request->withBody($body); |
@@ -18,7 +18,7 @@ |
||
18 | 18 | |
19 | 19 | /** |
20 | 20 | */ |
21 | -abstract class AzureActiveDirectory extends OAuth2Provider implements CSRFToken{ |
|
21 | +abstract class AzureActiveDirectory extends OAuth2Provider implements CSRFToken { |
|
22 | 22 | |
23 | 23 | public const SCOPE_OPENID = 'openid'; |
24 | 24 | public const SCOPE_OPENID_EMAIL = 'email'; |