@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | use chillerlan\OAuth\Core\{AccessToken, OAuthProvider, ProviderException}; |
| 16 | 16 | use Psr\Http\Message\{RequestInterface, ResponseInterface, UriInterface}; |
| 17 | 17 | |
| 18 | -use function array_merge, http_build_query, in_array, is_array,ksort, md5; |
|
| 18 | +use function array_merge, http_build_query, in_array, is_array, ksort, md5; |
|
| 19 | 19 | use function chillerlan\HTTP\Psr7\{get_json, merge_query}; |
| 20 | 20 | |
| 21 | 21 | use const PHP_QUERY_RFC1738; |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * @method \Psr\Http\Message\ResponseInterface userGetWeeklyChartList(array $params = ['user']) |
| 76 | 76 | * @method \Psr\Http\Message\ResponseInterface userGetWeeklyTrackChart(array $params = ['from', 'to', 'user']) |
| 77 | 77 | */ |
| 78 | -class LastFM extends OAuthProvider{ |
|
| 78 | +class LastFM extends OAuthProvider { |
|
| 79 | 79 | |
| 80 | 80 | public const PERIOD_OVERALL = 'overall'; |
| 81 | 81 | public const PERIOD_7DAY = '7day'; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | self::PERIOD_12MONTH, |
| 94 | 94 | ]; |
| 95 | 95 | |
| 96 | - protected string $authURL = 'https://www.last.fm/api/auth'; |
|
| 96 | + protected string $authURL = 'https://www.last.fm/api/auth'; |
|
| 97 | 97 | protected ?string $apiURL = 'https://ws.audioscrobbler.com/2.0'; |
| 98 | 98 | protected ?string $userRevokeURL = 'https://www.last.fm/settings/applications'; |
| 99 | 99 | protected ?string $endpointMap = LastFMEndpoints::class; |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | $signature = ''; |
| 124 | 124 | |
| 125 | - foreach($params as $k => $v){ |
|
| 126 | - if(!in_array($k, ['format', 'callback'])){ |
|
| 125 | + foreach ($params as $k => $v) { |
|
| 126 | + if (!in_array($k, ['format', 'callback'])) { |
|
| 127 | 127 | $signature .= $k.$v; |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -162,13 +162,13 @@ discard block |
||
| 162 | 162 | protected function parseTokenResponse(ResponseInterface $response):AccessToken{ |
| 163 | 163 | $data = get_json($response, true); |
| 164 | 164 | |
| 165 | - if(!$data || !is_array($data)){ |
|
| 165 | + if (!$data || !is_array($data)) { |
|
| 166 | 166 | throw new ProviderException('unable to parse token response'); |
| 167 | 167 | } |
| 168 | - elseif(isset($data['error'])){ |
|
| 168 | + elseif (isset($data['error'])) { |
|
| 169 | 169 | throw new ProviderException('error retrieving access token: '.$data['message']); |
| 170 | 170 | } |
| 171 | - elseif(!isset($data['session']['key'])){ |
|
| 171 | + elseif (!isset($data['session']['key'])) { |
|
| 172 | 172 | throw new ProviderException('token missing'); |
| 173 | 173 | } |
| 174 | 174 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | $params['api_sig'] = $this->getSignature($params); |
| 210 | 210 | |
| 211 | - if($method === 'POST'){ |
|
| 211 | + if ($method === 'POST') { |
|
| 212 | 212 | $body = $params; |
| 213 | 213 | $params = []; |
| 214 | 214 | } |
@@ -216,11 +216,11 @@ discard block |
||
| 216 | 216 | /** @phan-suppress-next-line PhanTypeMismatchArgumentNullable */ |
| 217 | 217 | $request = $this->requestFactory->createRequest($method, merge_query($this->apiURL, $params)); |
| 218 | 218 | |
| 219 | - foreach(array_merge($this->apiHeaders, $headers ?? []) as $header => $value){ |
|
| 219 | + foreach (array_merge($this->apiHeaders, $headers ?? []) as $header => $value) { |
|
| 220 | 220 | $request = $request->withAddedHeader($header, $value); |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - if($method === 'POST'){ |
|
| 223 | + if ($method === 'POST') { |
|
| 224 | 224 | $request = $request->withHeader('Content-Type', 'application/x-www-form-urlencoded'); |
| 225 | 225 | $body = $this->streamFactory->createStream(http_build_query($body, '', '&', PHP_QUERY_RFC1738)); |
| 226 | 226 | $request = $request->withBody($body); |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | |
| 12 | 12 | use chillerlan\OAuth\MagicAPI\EndpointMap; |
| 13 | 13 | |
| 14 | -class LastFMEndpoints extends EndpointMap{ |
|
| 14 | +class LastFMEndpoints extends EndpointMap { |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * Tag an album using a list of user supplied tags. |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | |
| 12 | 12 | use chillerlan\OAuth\MagicAPI\EndpointMap; |
| 13 | 13 | |
| 14 | -class SoundCloudEndpoints extends EndpointMap{ |
|
| 14 | +class SoundCloudEndpoints extends EndpointMap { |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * Returns the authenticated user’s information. |
@@ -74,7 +74,7 @@ |
||
| 74 | 74 | * @method \Psr\Http\Message\ResponseInterface usersUserIdTracks(string $user_id, array $params = ['limit', 'linked_partitioning']) |
| 75 | 75 | * @method \Psr\Http\Message\ResponseInterface usersUserIdWebProfiles(string $user_id, array $params = ['limit']) |
| 76 | 76 | */ |
| 77 | -class SoundCloud extends OAuth2Provider{ |
|
| 77 | +class SoundCloud extends OAuth2Provider { |
|
| 78 | 78 | |
| 79 | 79 | public const SCOPE_NONEXPIRING = 'non-expiring'; |
| 80 | 80 | # public const SCOPE_EMAIL = 'email'; // ??? |