@@ -120,7 +120,7 @@ |
||
120 | 120 | public function setInstance(string $instance):Mastodon{ |
121 | 121 | $instance = parseUrl($instance); |
122 | 122 | |
123 | - if(!isset($instance['scheme']) || !isset($instance['host'])){ |
|
123 | + if (!isset($instance['scheme']) || !isset($instance['host'])) { |
|
124 | 124 | throw new OAuthException('invalid instance URL'); |
125 | 125 | } |
126 | 126 |
@@ -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, $this->mergeQuery($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($this->buildQuery($body, PHP_QUERY_RFC1738)); |
226 | 226 | $request = $request->withBody($body); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | protected array $authHeaders = ['Accept' => 'application/vnd.twitchtv.v5+json']; |
116 | 116 | protected array $apiHeaders = ['Accept' => 'application/vnd.twitchtv.v5+json']; |
117 | 117 | |
118 | - protected array $defaultScopes = [ |
|
118 | + protected array $defaultScopes = [ |
|
119 | 119 | self::SCOPE_USER_READ_EMAIL, |
120 | 120 | ]; |
121 | 121 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | 'grant_type' => 'client_credentials', |
134 | 134 | ]; |
135 | 135 | |
136 | - if($scopes !== null){ |
|
136 | + if ($scopes !== null) { |
|
137 | 137 | $params['scope'] = implode($this->scopesDelimiter, $scopes); |
138 | 138 | } |
139 | 139 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | ->withBody($this->streamFactory->createStream($this->buildQuery($params, PHP_QUERY_RFC1738))) |
144 | 144 | ; |
145 | 145 | |
146 | - foreach($this->authHeaders as $header => $value){ |
|
146 | + foreach ($this->authHeaders as $header => $value) { |
|
147 | 147 | $request = $request->withAddedHeader($header, $value); |
148 | 148 | } |
149 | 149 |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @method \Psr\Http\Message\ResponseInterface steamWebAPIUtilGetSupportedAPIList() |
48 | 48 | * @method \Psr\Http\Message\ResponseInterface storeServiceGetAppList(array $params = ['if_modified_since', 'have_description_language', 'include_games', 'include_dlc', 'include_software', 'include_videos', 'include_hardware', 'last_appid', 'max_results']) |
49 | 49 | */ |
50 | -class SteamOpenID extends OAuthProvider{ |
|
50 | +class SteamOpenID extends OAuthProvider { |
|
51 | 51 | |
52 | 52 | protected string $authURL = 'https://steamcommunity.com/openid/login'; |
53 | 53 | protected string $accessTokenURL = 'https://steamcommunity.com/openid/login'; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | 'openid.sig' => $received['openid_sig'], |
90 | 90 | ]; |
91 | 91 | |
92 | - foreach(explode(',', $received['openid_signed']) as $item){ |
|
92 | + foreach (explode(',', $received['openid_signed']) as $item) { |
|
93 | 93 | $body['openid.'.$item] = $received['openid_'.$item]; |
94 | 94 | } |
95 | 95 | |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | protected function parseTokenResponse(ResponseInterface $response):AccessToken{ |
125 | 125 | $data = explode("\x0a", (string)$response->getBody()); |
126 | 126 | |
127 | - if(!isset($data[1]) || strpos($data[1], 'is_valid') !== 0){ |
|
127 | + if (!isset($data[1]) || strpos($data[1], 'is_valid') !== 0) { |
|
128 | 128 | throw new ProviderException('unable to parse token response'); |
129 | 129 | } |
130 | 130 | |
131 | - if($data[1] !== 'is_valid:true'){ |
|
131 | + if ($data[1] !== 'is_valid:true') { |
|
132 | 132 | throw new ProviderException('invalid id'); |
133 | 133 | } |
134 | 134 | |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | $params = ['key' => $this->options->secret]; |
151 | 151 | |
152 | 152 | // the steamid parameter does not necessarily specify the current user, so add it only when it's not already set |
153 | - if(strpos($uri, 'steamid=') === false){ // php8: str_contains |
|
154 | - $params['steamid']= $token->accessToken; |
|
153 | + if (strpos($uri, 'steamid=') === false) { // php8: str_contains |
|
154 | + $params['steamid'] = $token->accessToken; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return $request->withUri($this->uriFactory->createUri($this->mergeQuery($uri, $params))); |
@@ -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 TwitterEndpoints extends TwitterCCEndpoints{ |
|
20 | +class TwitterEndpoints extends TwitterCCEndpoints { |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * 1 Basics |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | 'method' => 'POST', |
122 | 122 | 'query' => null, |
123 | 123 | 'path_elements' => null, |
124 | - 'body' => ['name', 'url', 'location', 'description', 'profile_link_color', 'include_entities', 'skip_status',], |
|
124 | + 'body' => ['name', 'url', 'location', 'description', 'profile_link_color', 'include_entities', 'skip_status', ], |
|
125 | 125 | 'headers' => null, |
126 | 126 | ]; |
127 | 127 |
@@ -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 | protected string $API_BASE = '/1.1'; |
23 | 23 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | protected array $friendshipsShow = [ |
82 | 82 | 'path' => '/friendships/show.json', |
83 | 83 | 'method' => 'GET', |
84 | - 'query' => ['source_id', 'source_screen_name', 'target_id', 'target_screen_name',], |
|
84 | + 'query' => ['source_id', 'source_screen_name', 'target_id', 'target_screen_name', ], |
|
85 | 85 | 'path_elements' => null, |
86 | 86 | 'body' => null, |
87 | 87 | 'headers' => null, |
@@ -55,7 +55,7 @@ |
||
55 | 55 | * @method \Psr\Http\Message\ResponseInterface usersSearch(array $params = ['q', 'page', 'count', 'include_entities', 'skip_status']) |
56 | 56 | * @method \Psr\Http\Message\ResponseInterface usersShow(array $params = ['user_id', 'screen_name', 'include_entities', 'skip_status']) |
57 | 57 | */ |
58 | -class TwitterCC extends OAuth2Provider implements ClientCredentials{ |
|
58 | +class TwitterCC extends OAuth2Provider implements ClientCredentials { |
|
59 | 59 | |
60 | 60 | protected const AUTH_ERRMSG = 'TwitterCC only supports Client Credentials Grant, use the Twitter OAuth1 class for authentication instead.'; |
61 | 61 |
@@ -124,11 +124,11 @@ |
||
124 | 124 | * @method \Psr\Http\Message\ResponseInterface usersShow(array $params = ['user_id', 'screen_name', 'include_entities', 'skip_status']) |
125 | 125 | * @method \Psr\Http\Message\ResponseInterface verifyCredentials(array $params = ['include_entities', 'skip_status']) |
126 | 126 | */ |
127 | -class Twitter extends OAuth1Provider{ |
|
127 | +class Twitter extends OAuth1Provider { |
|
128 | 128 | |
129 | 129 | // choose your fighter |
130 | 130 | /** @link https://developer.twitter.com/en/docs/basics/authentication/api-reference/authorize */ |
131 | - protected string $authURL = 'https://api.twitter.com/oauth/authorize'; |
|
131 | + protected string $authURL = 'https://api.twitter.com/oauth/authorize'; |
|
132 | 132 | /** @link https://developer.twitter.com/en/docs/basics/authentication/api-reference/authenticate */ |
133 | 133 | # protected string $authURL = 'https://api.twitter.com/oauth/authenticate'; |
134 | 134 |