@@ -27,17 +27,17 @@ discard block |
||
27 | 27 | { |
28 | 28 | parent::configure(); |
29 | 29 | |
30 | - if (!$this->config->exists('url')) { |
|
30 | + if ( ! $this->config->exists('url')) { |
|
31 | 31 | throw new InvalidApplicationCredentialsException( |
32 | 32 | 'You must define a Mastodon instance url' |
33 | 33 | ); |
34 | 34 | } |
35 | 35 | $url = $this->config->get('url'); |
36 | 36 | |
37 | - $this->apiBaseUrl = $url . '/api/v1'; |
|
37 | + $this->apiBaseUrl = $url.'/api/v1'; |
|
38 | 38 | |
39 | - $this->authorizeUrl = $url . '/oauth/authorize'; |
|
40 | - $this->accessTokenUrl = $url . '/oauth/token'; |
|
39 | + $this->authorizeUrl = $url.'/oauth/authorize'; |
|
40 | + $this->accessTokenUrl = $url.'/oauth/token'; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | $data = new Data\Collection($response); |
51 | 51 | |
52 | - if (!$data->exists('id') || !$data->get('id')) { |
|
52 | + if ( ! $data->exists('id') || ! $data->get('id')) { |
|
53 | 53 | throw new UnexpectedApiResponseException( |
54 | 54 | 'Provider API returned an unexpected response.' |
55 | 55 | ); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | foreach ($pictures as $picture) { |
89 | 89 | $images = $this->apiRequest( |
90 | - $this->config->get('url') . '/api/v2/media', |
|
90 | + $this->config->get('url').'/api/v2/media', |
|
91 | 91 | 'POST', |
92 | 92 | [ |
93 | 93 | 'file' => new \CurlFile( |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $verifyTokenSignature = |
182 | 182 | $this->config->exists('verifyTokenSignature') ? $this->config->get('verifyTokenSignature') : true; |
183 | 183 | |
184 | - if (!$verifyTokenSignature) { |
|
184 | + if ( ! $verifyTokenSignature) { |
|
185 | 185 | // payload extraction by https://github.com/omidborjian |
186 | 186 | // https://github.com/hybridauth/hybridauth/issues/1095#issuecomment-626479263 |
187 | 187 | // JWT splits the string to 3 components 1) first is header 2) is payload 3) is signature |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | |
199 | 199 | foreach ($publicKeys->keys as $publicKey) { |
200 | 200 | try { |
201 | - $jwk = (array)$publicKey; |
|
201 | + $jwk = (array) $publicKey; |
|
202 | 202 | |
203 | 203 | $key = PublicKeyLoader::load( |
204 | 204 | [ |
@@ -209,11 +209,10 @@ discard block |
||
209 | 209 | ->withHash('sha1') |
210 | 210 | ->withMGFHash('sha1'); |
211 | 211 | |
212 | - $pem = (string)$key; |
|
212 | + $pem = (string) $key; |
|
213 | 213 | |
214 | 214 | $payload = (version_compare($this->getJwtVersion(), '6.2') < 0) ? |
215 | - JWT::decode($id_token, $pem, ['RS256']) : |
|
216 | - JWT::decode($id_token, new Key($pem, 'RS256')); |
|
215 | + JWT::decode($id_token, $pem, ['RS256']) : JWT::decode($id_token, new Key($pem, 'RS256')); |
|
217 | 216 | break; |
218 | 217 | } catch (Exception $e) { |
219 | 218 | $error = $e->getMessage(); |
@@ -223,14 +222,14 @@ discard block |
||
223 | 222 | } |
224 | 223 | } |
225 | 224 | |
226 | - if ($error && !$payload) { |
|
225 | + if ($error && ! $payload) { |
|
227 | 226 | throw new Exception($error); |
228 | 227 | } |
229 | 228 | } |
230 | 229 | |
231 | 230 | $data = new Data\Collection($payload); |
232 | 231 | |
233 | - if (!$data->exists('sub')) { |
|
232 | + if ( ! $data->exists('sub')) { |
|
234 | 233 | throw new UnexpectedValueException('Missing token payload.'); |
235 | 234 | } |
236 | 235 | |
@@ -239,12 +238,12 @@ discard block |
||
239 | 238 | $userProfile->email = $data->get('email'); |
240 | 239 | $this->storeData('expires_at', $data->get('exp')); |
241 | 240 | |
242 | - if (!empty($_REQUEST['user'])) { |
|
241 | + if ( ! empty($_REQUEST['user'])) { |
|
243 | 242 | $objUser = json_decode($_REQUEST['user']); |
244 | 243 | $user = new Data\Collection($objUser); |
245 | - if (!$user->isEmpty()) { |
|
244 | + if ( ! $user->isEmpty()) { |
|
246 | 245 | $name = $user->get('name'); |
247 | - if (!empty($name->firstName)) { |
|
246 | + if ( ! empty($name->firstName)) { |
|
248 | 247 | $userProfile->firstName = $name->firstName; |
249 | 248 | $userProfile->lastName = $name->lastName; |
250 | 249 | $userProfile->displayName = join(' ', [$userProfile->firstName, $userProfile->lastName]); |
@@ -266,7 +265,7 @@ discard block |
||
266 | 265 | // Your 10-character Team ID |
267 | 266 | $team_id = $this->config->filter('keys')->get('team_id'); |
268 | 267 | |
269 | - if (!$team_id) { |
|
268 | + if ( ! $team_id) { |
|
270 | 269 | throw new InvalidApplicationCredentialsException( |
271 | 270 | 'Missing parameter team_id: your team id is required to generate the JWS token.' |
272 | 271 | ); |
@@ -275,7 +274,7 @@ discard block |
||
275 | 274 | // Your Services ID, e.g. com.aaronparecki.services |
276 | 275 | $client_id = $this->config->filter('keys')->get('id') ?: $this->config->filter('keys')->get('key'); |
277 | 276 | |
278 | - if (!$client_id) { |
|
277 | + if ( ! $client_id) { |
|
279 | 278 | throw new InvalidApplicationCredentialsException( |
280 | 279 | 'Missing parameter id: your client id is required to generate the JWS token.' |
281 | 280 | ); |
@@ -284,7 +283,7 @@ discard block |
||
284 | 283 | // Find the 10-char Key ID value from the portal |
285 | 284 | $key_id = $this->config->filter('keys')->get('key_id'); |
286 | 285 | |
287 | - if (!$key_id) { |
|
286 | + if ( ! $key_id) { |
|
288 | 287 | throw new InvalidApplicationCredentialsException( |
289 | 288 | 'Missing parameter key_id: your key id is required to generate the JWS token.' |
290 | 289 | ); |
@@ -294,16 +293,16 @@ discard block |
||
294 | 293 | $key_content = $this->config->filter('keys')->get('key_content'); |
295 | 294 | |
296 | 295 | // Save your private key from Apple in a file called `key.txt` |
297 | - if (!$key_content) { |
|
296 | + if ( ! $key_content) { |
|
298 | 297 | $key_file = $this->config->filter('keys')->get('key_file'); |
299 | 298 | |
300 | - if (!$key_file) { |
|
299 | + if ( ! $key_file) { |
|
301 | 300 | throw new InvalidApplicationCredentialsException( |
302 | 301 | 'Missing parameter key_content or key_file: your key is required to generate the JWS token.' |
303 | 302 | ); |
304 | 303 | } |
305 | 304 | |
306 | - if (!file_exists($key_file)) { |
|
305 | + if ( ! file_exists($key_file)) { |
|
307 | 306 | throw new InvalidApplicationCredentialsException( |
308 | 307 | "Your key file $key_file does not exist." |
309 | 308 | ); |
@@ -335,7 +334,6 @@ discard block |
||
335 | 334 | { |
336 | 335 | // assume old JWT version if no version check is possible because composer 1 is installed |
337 | 336 | return class_exists('Composer\InstalledVersions') ? |
338 | - InstalledVersions::getVersion('firebase/php-jwt') : |
|
339 | - ''; |
|
337 | + InstalledVersions::getVersion('firebase/php-jwt') : ''; |
|
340 | 338 | } |
341 | 339 | } |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | $this->clientId = $this->config->filter('keys')->get('id') ?: $this->config->filter('keys')->get('key'); |
250 | 250 | $this->clientSecret = $this->config->filter('keys')->get('secret'); |
251 | 251 | |
252 | - if (!$this->clientId || !$this->clientSecret) { |
|
252 | + if ( ! $this->clientId || ! $this->clientSecret) { |
|
253 | 253 | throw new InvalidApplicationCredentialsException( |
254 | - 'Your application id is required in order to connect to ' . $this->providerId |
|
254 | + 'Your application id is required in order to connect to '.$this->providerId |
|
255 | 255 | ); |
256 | 256 | } |
257 | 257 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | ]; |
290 | 290 | |
291 | 291 | $refreshToken = $this->getStoredData('refresh_token'); |
292 | - if (!empty($refreshToken)) { |
|
292 | + if ( ! empty($refreshToken)) { |
|
293 | 293 | $this->tokenRefreshParameters = [ |
294 | 294 | 'grant_type' => 'refresh_token', |
295 | 295 | 'refresh_token' => $refreshToken, |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | } |
298 | 298 | |
299 | 299 | $this->apiRequestHeaders = [ |
300 | - 'Authorization' => 'Bearer ' . $this->getStoredData('access_token') |
|
300 | + 'Authorization' => 'Bearer '.$this->getStoredData('access_token') |
|
301 | 301 | ]; |
302 | 302 | } |
303 | 303 | |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | */ |
337 | 337 | public function isConnected() |
338 | 338 | { |
339 | - if ((bool)$this->getStoredData('access_token')) { |
|
340 | - return (!$this->hasAccessTokenExpired() || $this->isRefreshTokenAvailable()); |
|
339 | + if ((bool) $this->getStoredData('access_token')) { |
|
340 | + return ( ! $this->hasAccessTokenExpired() || $this->isRefreshTokenAvailable()); |
|
341 | 341 | } |
342 | 342 | return false; |
343 | 343 | } |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | { |
369 | 369 | $error = filter_input(INPUT_GET, 'error', FILTER_SANITIZE_SPECIAL_CHARS); |
370 | 370 | |
371 | - if (!empty($error)) { |
|
371 | + if ( ! empty($error)) { |
|
372 | 372 | $error_description = filter_input(INPUT_GET, 'error_description', FILTER_SANITIZE_SPECIAL_CHARS); |
373 | 373 | $error_uri = filter_input(INPUT_GET, 'error_uri', FILTER_SANITIZE_SPECIAL_CHARS); |
374 | 374 | |
@@ -425,11 +425,11 @@ discard block |
||
425 | 425 | * http://tools.ietf.org/html/rfc6749#section-4.1.1 |
426 | 426 | */ |
427 | 427 | if ($this->supportRequestState |
428 | - && (!$state || $this->getStoredData('authorization_state') != $state) |
|
428 | + && ( ! $state || $this->getStoredData('authorization_state') != $state) |
|
429 | 429 | ) { |
430 | 430 | $this->deleteStoredData('authorization_state'); |
431 | 431 | throw new InvalidAuthorizationStateException( |
432 | - 'The authorization state [state=' . substr(htmlentities($state), 0, 100) . '] ' |
|
432 | + 'The authorization state [state='.substr(htmlentities($state), 0, 100).'] ' |
|
433 | 433 | . 'of this page is either invalid or has already been consumed.' |
434 | 434 | ); |
435 | 435 | } |
@@ -471,23 +471,23 @@ discard block |
||
471 | 471 | */ |
472 | 472 | protected function getAuthorizeUrl($parameters = []) |
473 | 473 | { |
474 | - $this->AuthorizeUrlParameters = !empty($parameters) |
|
474 | + $this->AuthorizeUrlParameters = ! empty($parameters) |
|
475 | 475 | ? $parameters |
476 | 476 | : array_replace( |
477 | - (array)$this->AuthorizeUrlParameters, |
|
478 | - (array)$this->config->get('authorize_url_parameters') |
|
477 | + (array) $this->AuthorizeUrlParameters, |
|
478 | + (array) $this->config->get('authorize_url_parameters') |
|
479 | 479 | ); |
480 | 480 | |
481 | 481 | if ($this->supportRequestState) { |
482 | - if (!isset($this->AuthorizeUrlParameters['state'])) { |
|
483 | - $this->AuthorizeUrlParameters['state'] = 'HA-' . str_shuffle('ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'); |
|
482 | + if ( ! isset($this->AuthorizeUrlParameters['state'])) { |
|
483 | + $this->AuthorizeUrlParameters['state'] = 'HA-'.str_shuffle('ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | $this->storeData('authorization_state', $this->AuthorizeUrlParameters['state']); |
487 | 487 | } |
488 | 488 | |
489 | 489 | $queryParams = http_build_query($this->AuthorizeUrlParameters, '', '&', $this->AuthorizeUrlParametersEncType); |
490 | - return $this->authorizeUrl . '?' . $queryParams; |
|
490 | + return $this->authorizeUrl.'?'.$queryParams; |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | /** |
@@ -567,9 +567,9 @@ discard block |
||
567 | 567 | |
568 | 568 | $collection = new Data\Collection($data); |
569 | 569 | |
570 | - if (!$collection->exists('access_token')) { |
|
570 | + if ( ! $collection->exists('access_token')) { |
|
571 | 571 | throw new InvalidAccessTokenException( |
572 | - 'Provider returned no access_token: ' . htmlentities($response) |
|
572 | + 'Provider returned no access_token: '.htmlentities($response) |
|
573 | 573 | ); |
574 | 574 | } |
575 | 575 | |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | |
583 | 583 | // calculate when the access token expire |
584 | 584 | if ($collection->exists('expires_in')) { |
585 | - $expires_at = time() + (int)$collection->get('expires_in'); |
|
585 | + $expires_at = time() + (int) $collection->get('expires_in'); |
|
586 | 586 | |
587 | 587 | $this->storeData('expires_in', $collection->get('expires_in')); |
588 | 588 | $this->storeData('expires_at', $expires_at); |
@@ -620,11 +620,11 @@ discard block |
||
620 | 620 | */ |
621 | 621 | public function refreshAccessToken($parameters = []) |
622 | 622 | { |
623 | - $this->tokenRefreshParameters = !empty($parameters) |
|
623 | + $this->tokenRefreshParameters = ! empty($parameters) |
|
624 | 624 | ? $parameters |
625 | 625 | : $this->tokenRefreshParameters; |
626 | 626 | |
627 | - if (!$this->isRefreshTokenAvailable()) { |
|
627 | + if ( ! $this->isRefreshTokenAvailable()) { |
|
628 | 628 | return null; |
629 | 629 | } |
630 | 630 | |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | } |
656 | 656 | |
657 | 657 | $expires_at = $this->getStoredData('expires_at'); |
658 | - if (!$expires_at) { |
|
658 | + if ( ! $expires_at) { |
|
659 | 659 | return null; |
660 | 660 | } |
661 | 661 | |
@@ -721,21 +721,21 @@ discard block |
||
721 | 721 | } |
722 | 722 | |
723 | 723 | if (strrpos($url, 'http://') !== 0 && strrpos($url, 'https://') !== 0) { |
724 | - $url = rtrim($this->apiBaseUrl, '/') . '/' . ltrim($url, '/'); |
|
724 | + $url = rtrim($this->apiBaseUrl, '/').'/'.ltrim($url, '/'); |
|
725 | 725 | } |
726 | 726 | |
727 | - $parameters = array_replace($this->apiRequestParameters, (array)$parameters); |
|
728 | - $headers = array_replace($this->apiRequestHeaders, (array)$headers); |
|
727 | + $parameters = array_replace($this->apiRequestParameters, (array) $parameters); |
|
728 | + $headers = array_replace($this->apiRequestHeaders, (array) $headers); |
|
729 | 729 | |
730 | 730 | $response = $this->httpClient->request( |
731 | 731 | $url, |
732 | - $method, // HTTP Request Method. Defaults to GET. |
|
732 | + $method, // HTTP Request Method. Defaults to GET. |
|
733 | 733 | $parameters, // Request Parameters |
734 | - $headers, // Request Headers |
|
734 | + $headers, // Request Headers |
|
735 | 735 | $multipart // Is request multipart |
736 | 736 | ); |
737 | 737 | |
738 | - $this->validateApiResponse('Signed API request to ' . $url . ' has returned an error'); |
|
738 | + $this->validateApiResponse('Signed API request to '.$url.' has returned an error'); |
|
739 | 739 | |
740 | 740 | $response = (new Data\Parser())->parse($response); |
741 | 741 |
@@ -66,7 +66,7 @@ |
||
66 | 66 | $response = $this->apiRequest('/userinfo', 'GET', []); |
67 | 67 | $data = new Data\Collection($response); |
68 | 68 | |
69 | - if (!$data->exists('sub')) { |
|
69 | + if ( ! $data->exists('sub')) { |
|
70 | 70 | throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
71 | 71 | } |
72 | 72 |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | $this->apiRequestParameters = [ |
81 | 81 | 'access_token' => $this->getStoredData('access_token'), |
82 | - 'fmt' => $this>responseDataFormat |
|
82 | + 'fmt' => $this > responseDataFormat |
|
83 | 83 | ]; |
84 | 84 | |
85 | 85 | $this->apiRequestHeaders = []; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | $resp = $this->apiRequest($this->accessTokenInfoUrl); |
96 | 96 | |
97 | - if (!isset($resp->openid)) { |
|
97 | + if ( ! isset($resp->openid)) { |
|
98 | 98 | throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
99 | 99 | } |
100 | 100 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $userRequestParameters = [ |
114 | 114 | 'oauth_consumer_key' => $this->clientId, |
115 | 115 | 'openid' => $openid, |
116 | - 'format' => $this>responseDataFormat |
|
116 | + 'format' => $this > responseDataFormat |
|
117 | 117 | ]; |
118 | 118 | |
119 | 119 | $response = $this->apiRequest($this->accessUserInfo, 'GET', $userRequestParameters); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $data = new Data\Collection($response); |
122 | 122 | |
123 | 123 | if ($data->get('ret') < 0) { |
124 | - throw new UnexpectedApiResponseException('Provider API returned an error: ' . $data->get('msg')); |
|
124 | + throw new UnexpectedApiResponseException('Provider API returned an error: '.$data->get('msg')); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | $userProfile = new Profile(); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function maintainToken() |
102 | 102 | { |
103 | - if (!$this->isConnected()) { |
|
103 | + if ( ! $this->isConnected()) { |
|
104 | 104 | return; |
105 | 105 | } |
106 | 106 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $exchange_by_expiry_days = $this->config->get('exchange_by_expiry_days') ?: 45; |
109 | 109 | if ($exchange_by_expiry_days !== null) { |
110 | 110 | $projected_timestamp = time() + 60 * 60 * 24 * $exchange_by_expiry_days; |
111 | - if (!$this->hasAccessTokenExpired() && $this->hasAccessTokenExpired($projected_timestamp)) { |
|
111 | + if ( ! $this->hasAccessTokenExpired() && $this->hasAccessTokenExpired($projected_timestamp)) { |
|
112 | 112 | $this->exchangeAccessToken(); |
113 | 113 | } |
114 | 114 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | |
190 | 190 | $data = new Data\Collection($response); |
191 | 191 | |
192 | - if (!$data->exists('id')) { |
|
192 | + if ( ! $data->exists('id')) { |
|
193 | 193 | throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
194 | 194 | } |
195 | 195 | |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | |
216 | 216 | $photoSize = $this->config->get('photo_size') ?: '150'; |
217 | 217 | |
218 | - $userProfile->photoURL = $this->apiBaseUrl . $userProfile->identifier; |
|
219 | - $userProfile->photoURL .= '/picture?width=' . $photoSize . '&height=' . $photoSize; |
|
218 | + $userProfile->photoURL = $this->apiBaseUrl.$userProfile->identifier; |
|
219 | + $userProfile->photoURL .= '/picture?width='.$photoSize.'&height='.$photoSize; |
|
220 | 220 | |
221 | 221 | $userProfile->emailVerified = $userProfile->email; |
222 | 222 | |
@@ -238,13 +238,13 @@ discard block |
||
238 | 238 | |
239 | 239 | $kid = $this->getKidFromOLDCToken($accessToken); |
240 | 240 | |
241 | - if (!$kid) { |
|
241 | + if ( ! $kid) { |
|
242 | 242 | return null; |
243 | 243 | } |
244 | 244 | |
245 | 245 | $clientId = $this->config->filter('keys')->get('id') ?: $this->config->filter('keys')->get('key'); |
246 | 246 | |
247 | - if (!$clientId) { |
|
247 | + if ( ! $clientId) { |
|
248 | 248 | throw new InvalidApplicationCredentialsException( |
249 | 249 | 'Missing parameter id: your client id is required to generate the JWS token.' |
250 | 250 | ); |
@@ -254,16 +254,16 @@ discard block |
||
254 | 254 | |
255 | 255 | $publicKeys = new Data\Collection($response); |
256 | 256 | |
257 | - if (!$publicKeys->exists('keys') || !$publicKeys->get('keys')) { |
|
257 | + if ( ! $publicKeys->exists('keys') || ! $publicKeys->get('keys')) { |
|
258 | 258 | throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
259 | 259 | } |
260 | 260 | |
261 | - $filteredKeys = array_filter($publicKeys->get('keys'), function ($k) use ($kid) { |
|
261 | + $filteredKeys = array_filter($publicKeys->get('keys'), function($k) use ($kid) { |
|
262 | 262 | return $k->kid === $kid; |
263 | 263 | }); |
264 | 264 | |
265 | 265 | if (empty($filteredKeys)) { |
266 | - throw new UnexpectedValueException('Unable to find key with kid: ' . $kid); |
|
266 | + throw new UnexpectedValueException('Unable to find key with kid: '.$kid); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | $jwk = array_shift($filteredKeys); |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | */ |
310 | 310 | protected function fetchUserRegion(User\Profile $userProfile) |
311 | 311 | { |
312 | - if (!empty($userProfile->region)) { |
|
312 | + if ( ! empty($userProfile->region)) { |
|
313 | 313 | $regionArr = explode(',', $userProfile->region); |
314 | 314 | |
315 | 315 | if (count($regionArr) > 1) { |
@@ -333,9 +333,9 @@ discard block |
||
333 | 333 | { |
334 | 334 | $result = (new Data\Parser())->parseBirthday($birthday); |
335 | 335 | |
336 | - $userProfile->birthYear = (int)$result[0]; |
|
337 | - $userProfile->birthMonth = (int)$result[1]; |
|
338 | - $userProfile->birthDay = (int)$result[2]; |
|
336 | + $userProfile->birthYear = (int) $result[0]; |
|
337 | + $userProfile->birthMonth = (int) $result[1]; |
|
338 | + $userProfile->birthDay = (int) $result[2]; |
|
339 | 339 | |
340 | 340 | return $userProfile; |
341 | 341 | } |
@@ -358,11 +358,11 @@ discard block |
||
358 | 358 | |
359 | 359 | $data = new Data\Collection($response); |
360 | 360 | |
361 | - if (!$data->exists('data')) { |
|
361 | + if ( ! $data->exists('data')) { |
|
362 | 362 | throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
363 | 363 | } |
364 | 364 | |
365 | - if (!$data->filter('data')->isEmpty()) { |
|
365 | + if ( ! $data->filter('data')->isEmpty()) { |
|
366 | 366 | foreach ($data->filter('data')->toArray() as $item) { |
367 | 367 | $contacts[] = $this->fetchUserContact($item); |
368 | 368 | } |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | $userContact->profileURL = $item->exists('link') |
400 | 400 | ?: $this->getProfileUrl($userContact->identifier); |
401 | 401 | |
402 | - $userContact->photoURL = $this->apiBaseUrl . $userContact->identifier . '/picture?width=150&height=150'; |
|
402 | + $userContact->photoURL = $this->apiBaseUrl.$userContact->identifier.'/picture?width=150&height=150'; |
|
403 | 403 | |
404 | 404 | return $userContact; |
405 | 405 | } |
@@ -418,11 +418,11 @@ discard block |
||
418 | 418 | |
419 | 419 | // Retrieve writable user pages and filter by given one. |
420 | 420 | $pages = $this->getUserPages(true); |
421 | - $pages = array_filter($pages, function ($page) use ($pageId) { |
|
421 | + $pages = array_filter($pages, function($page) use ($pageId) { |
|
422 | 422 | return $page->id == $pageId; |
423 | 423 | }); |
424 | 424 | |
425 | - if (!$pages) { |
|
425 | + if ( ! $pages) { |
|
426 | 426 | throw new InvalidArgumentException('Could not find a page with given id.'); |
427 | 427 | } |
428 | 428 | |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | |
431 | 431 | // Use page access token instead of user access token. |
432 | 432 | $headers = [ |
433 | - 'Authorization' => 'Bearer ' . $page->access_token, |
|
433 | + 'Authorization' => 'Bearer '.$page->access_token, |
|
434 | 434 | ]; |
435 | 435 | |
436 | 436 | // Refresh proof for API call. |
@@ -450,12 +450,12 @@ discard block |
||
450 | 450 | { |
451 | 451 | $pages = $this->apiRequest('me/accounts'); |
452 | 452 | |
453 | - if (!$writable) { |
|
453 | + if ( ! $writable) { |
|
454 | 454 | return $pages->data; |
455 | 455 | } |
456 | 456 | |
457 | 457 | // Filter user pages by CREATE_CONTENT permission. |
458 | - return array_filter($pages->data, function ($page) { |
|
458 | + return array_filter($pages->data, function($page) { |
|
459 | 459 | return in_array('CREATE_CONTENT', $page->tasks); |
460 | 460 | }); |
461 | 461 | } |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | |
472 | 472 | $data = new Data\Collection($response); |
473 | 473 | |
474 | - if (!$data->exists('data')) { |
|
474 | + if ( ! $data->exists('data')) { |
|
475 | 475 | throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
476 | 476 | } |
477 | 477 | |
@@ -510,13 +510,13 @@ discard block |
||
510 | 510 | $userActivity->text = $item->get('message'); |
511 | 511 | } |
512 | 512 | |
513 | - if (!empty($userActivity->text) && $item->exists('from')) { |
|
513 | + if ( ! empty($userActivity->text) && $item->exists('from')) { |
|
514 | 514 | $userActivity->user->identifier = $item->filter('from')->get('id'); |
515 | 515 | $userActivity->user->displayName = $item->filter('from')->get('name'); |
516 | 516 | |
517 | 517 | $userActivity->user->profileURL = $this->getProfileUrl($userActivity->user->identifier); |
518 | 518 | |
519 | - $userActivity->user->photoURL = $this->apiBaseUrl . $userActivity->user->identifier; |
|
519 | + $userActivity->user->photoURL = $this->apiBaseUrl.$userActivity->user->identifier; |
|
520 | 520 | $userActivity->user->photoURL .= '/picture?width=150&height=150'; |
521 | 521 | } |
522 | 522 | |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | |
540 | 540 | $payload = json_decode(base64_decode($segments[0] ?? '')); |
541 | 541 | |
542 | - if (!is_object($payload) || $payload?->kid === null) { |
|
542 | + if ( ! is_object($payload) || $payload?->kid === null) { |
|
543 | 543 | return null; |
544 | 544 | } |
545 | 545 | |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | */ |
555 | 555 | protected function getProfileUrl($identity) |
556 | 556 | { |
557 | - if (!is_numeric($identity)) { |
|
557 | + if ( ! is_numeric($identity)) { |
|
558 | 558 | return null; |
559 | 559 | } |
560 | 560 |
@@ -80,10 +80,10 @@ discard block |
||
80 | 80 | ]; |
81 | 81 | |
82 | 82 | $tenant = $this->config->get('tenant'); |
83 | - if (!empty($tenant)) { |
|
83 | + if ( ! empty($tenant)) { |
|
84 | 84 | $adjustedEndpoints = [ |
85 | - 'authorize_url' => str_replace('/common/', '/' . $tenant . '/', $this->authorizeUrl), |
|
86 | - 'access_token_url' => str_replace('/common/', '/' . $tenant . '/', $this->accessTokenUrl), |
|
85 | + 'authorize_url' => str_replace('/common/', '/'.$tenant.'/', $this->authorizeUrl), |
|
86 | + 'access_token_url' => str_replace('/common/', '/'.$tenant.'/', $this->accessTokenUrl), |
|
87 | 87 | ]; |
88 | 88 | |
89 | 89 | $this->setApiEndpoints($adjustedEndpoints); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | $data = new Data\Collection($response); |
108 | 108 | |
109 | - if (!$data->exists('id')) { |
|
109 | + if ( ! $data->exists('id')) { |
|
110 | 110 | throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
111 | 111 | } |
112 | 112 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | do { |
149 | 149 | $response = $this->apiRequest($apiUrl); |
150 | 150 | $data = new Data\Collection($response); |
151 | - if (!$data->exists('value')) { |
|
151 | + if ( ! $data->exists('value')) { |
|
152 | 152 | throw new UnexpectedApiResponseException('Provider API returned an unexpected response.'); |
153 | 153 | } |
154 | 154 | foreach ($data->filter('value')->toArray() as $entry) { |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | $userContact->identifier = $entry->get('id'); |
158 | 158 | $userContact->displayName = $entry->get('displayName'); |
159 | 159 | $emailAddresses = $entry->get('emailAddresses'); |
160 | - if (!empty($emailAddresses)) { |
|
160 | + if ( ! empty($emailAddresses)) { |
|
161 | 161 | $userContact->email = $emailAddresses[0]->address; |
162 | 162 | } |
163 | 163 | // only add to collection if we have usefull data |
164 | - if (!empty($userContact->displayName) || !empty($userContact->email)) { |
|
164 | + if ( ! empty($userContact->displayName) || ! empty($userContact->email)) { |
|
165 | 165 | $contacts[] = $userContact; |
166 | 166 | } |
167 | 167 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | ) { |
69 | 69 | if (is_string($config) && file_exists($config)) { |
70 | 70 | $config = include $config; |
71 | - } elseif (!is_array($config)) { |
|
71 | + } elseif ( ! is_array($config)) { |
|
72 | 72 | throw new InvalidArgumentException('Hybridauth config does not exist on the given path.'); |
73 | 73 | } |
74 | 74 | |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | |
121 | 121 | $adapter = isset($config['adapter']) ? $config['adapter'] : sprintf('Hybridauth\\Provider\\%s', $name); |
122 | 122 | |
123 | - if (!class_exists($adapter)) { |
|
123 | + if ( ! class_exists($adapter)) { |
|
124 | 124 | $unexistingConfiguredAdapter = $adapter; |
125 | 125 | $adapter = null; |
126 | - $fs = new \FilesystemIterator(__DIR__ . '/Provider/'); |
|
126 | + $fs = new \FilesystemIterator(__DIR__.'/Provider/'); |
|
127 | 127 | /** @var \SplFileInfo $file */ |
128 | 128 | foreach ($fs as $file) { |
129 | - if (!$file->isDir()) { |
|
129 | + if ( ! $file->isDir()) { |
|
130 | 130 | $provider = strtok($file->getFilename(), '.'); |
131 | 131 | if (mb_strtolower($name) === mb_strtolower($provider)) { |
132 | 132 | $adapter = sprintf('Hybridauth\\Provider\\%s', $provider); |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | |
159 | 159 | $providersConfig = array_change_key_case($this->config['providers'], CASE_LOWER); |
160 | 160 | |
161 | - if (!isset($providersConfig[$name])) { |
|
161 | + if ( ! isset($providersConfig[$name])) { |
|
162 | 162 | throw new InvalidArgumentException('Unknown Provider.'); |
163 | 163 | } |
164 | 164 | |
165 | - if (!$providersConfig[$name]['enabled']) { |
|
165 | + if ( ! $providersConfig[$name]['enabled']) { |
|
166 | 166 | throw new UnexpectedValueException('Disabled Provider.'); |
167 | 167 | } |
168 | 168 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | 'debug_file' => $this->config['debug_file'], |
173 | 173 | ]; |
174 | 174 | |
175 | - if (!isset($config['callback']) && isset($this->config['callback'])) { |
|
175 | + if ( ! isset($config['callback']) && isset($this->config['callback'])) { |
|
176 | 176 | $config['callback'] = $this->config['callback']; |
177 | 177 | } |
178 | 178 |