@@ -14,7 +14,7 @@ |
||
| 14 | 14 | |
| 15 | 15 | use chillerlan\OAuth\MagicAPI\EndpointMap; |
| 16 | 16 | |
| 17 | -class FlickrEndpoints extends EndpointMap{ |
|
| 17 | +class FlickrEndpoints extends EndpointMap { |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * @link https://www.flickr.com/services/api/flickr.activity.userComments.html |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | */ |
| 19 | -class BitbucketEndpoints extends EndpointMap{ |
|
| 19 | +class BitbucketEndpoints extends EndpointMap { |
|
| 20 | 20 | |
| 21 | 21 | protected string $API_BASE = '/2.0'; |
| 22 | 22 | |
@@ -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); |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | /** |
| 18 | 18 | * @link https://developer.wordpress.com/docs/api/ |
| 19 | 19 | */ |
| 20 | -class WordpressEndpoints extends EndpointMap{ |
|
| 20 | +class WordpressEndpoints extends EndpointMap { |
|
| 21 | 21 | |
| 22 | 22 | protected array $me = [ |
| 23 | 23 | 'path' => '/me', |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | * @method \Psr\Http\Message\ResponseInterface currentUser() |
| 21 | 21 | * @method \Psr\Http\Message\ResponseInterface currentUserCampaigns(array $params = ['includes']) |
| 22 | 22 | */ |
| 23 | -class Patreon1 extends PatreonAbstract{ |
|
| 23 | +class Patreon1 extends PatreonAbstract { |
|
| 24 | 24 | |
| 25 | 25 | public const SCOPE_USERS = 'users'; |
| 26 | 26 | public const SCOPE_PLEDGES_TO_ME = 'pledges-to-me'; |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | */ |
| 19 | -class Patreon2Endpoints extends EndpointMap{ |
|
| 19 | +class Patreon2Endpoints extends EndpointMap { |
|
| 20 | 20 | |
| 21 | 21 | protected string $API_BASE = '/v2'; |
| 22 | 22 | |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | */ |
| 19 | -class Patreon1Endpoints extends EndpointMap{ |
|
| 19 | +class Patreon1Endpoints extends EndpointMap { |
|
| 20 | 20 | |
| 21 | 21 | protected string $API_BASE = '/api'; |
| 22 | 22 | |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | * @method \Psr\Http\Message\ResponseInterface memberId(string $member_id, array $params = ['fields[member]', 'fields[tier]', 'fields[user]']) |
| 24 | 24 | * @method \Psr\Http\Message\ResponseInterface webhooks(array $params = ['fields[webhook]']) |
| 25 | 25 | */ |
| 26 | -class Patreon2 extends PatreonAbstract{ |
|
| 26 | +class Patreon2 extends PatreonAbstract { |
|
| 27 | 27 | |
| 28 | 28 | // wow, consistency... |
| 29 | 29 | public const SCOPE_IDENTITY = 'identity'; |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | protected ?string $endpointMap = TwitchEndpoints::class; |
| 56 | 56 | protected ?string $apiDocs = 'https://dev.twitch.tv/docs/api/reference/'; |
| 57 | 57 | protected ?string $applicationURL = 'https://dev.twitch.tv/console/apps/create'; |
| 58 | - protected string $authMethodHeader = 'OAuth'; // -> https://api.twitch.tv/kraken |
|
| 58 | + protected string $authMethodHeader = 'OAuth'; // -> https://api.twitch.tv/kraken |
|
| 59 | 59 | # protected string $authMethodHeader = 'Bearer'; // -> https://api.twitch.tv/helix |
| 60 | 60 | protected array $authHeaders = ['Accept' => 'application/vnd.twitchtv.v5+json']; |
| 61 | 61 | protected array $apiHeaders = ['Accept' => 'application/vnd.twitchtv.v5+json']; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | 'grant_type' => 'client_credentials', |
| 75 | 75 | ]; |
| 76 | 76 | |
| 77 | - if($scopes !== null){ |
|
| 77 | + if ($scopes !== null) { |
|
| 78 | 78 | $params['scope'] = implode($this->scopesDelimiter, $scopes); |
| 79 | 79 | } |
| 80 | 80 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | ->withBody($this->streamFactory->createStream(http_build_query($params, '', '&', PHP_QUERY_RFC1738))) |
| 85 | 85 | ; |
| 86 | 86 | |
| 87 | - foreach($this->authHeaders as $header => $value){ |
|
| 87 | + foreach ($this->authHeaders as $header => $value) { |
|
| 88 | 88 | $request = $request->withAddedHeader($header, $value); |
| 89 | 89 | } |
| 90 | 90 | |