@@ -83,7 +83,7 @@ |
||
| 83 | 83 | */ |
| 84 | 84 | public function has(string $key): bool |
| 85 | 85 | { |
| 86 | - return (bool) $this->get($key); |
|
| 86 | + return (bool)$this->get($key); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | public function offsetExists($offset) |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | { |
| 80 | 80 | $query = http_build_query($this->getCodeFields(), '', '&', $this->encodingType); |
| 81 | 81 | |
| 82 | - return $url . '?' . $query . '#wechat_redirect'; |
|
| 82 | + return $url.'?'.$query.'#wechat_redirect'; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | protected function getCodeFields(): array |
@@ -101,10 +101,10 @@ discard block |
||
| 101 | 101 | protected function getTokenUrl(): string |
| 102 | 102 | { |
| 103 | 103 | if (!empty($this->component)) { |
| 104 | - return $this->baseUrl . '/oauth2/component/access_token'; |
|
| 104 | + return $this->baseUrl.'/oauth2/component/access_token'; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - return $this->baseUrl . '/oauth2/access_token'; |
|
| 107 | + return $this->baseUrl.'/oauth2/access_token'; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | { |
| 139 | 139 | $language = $this->withCountryCode ? null : (isset($this->parameters['lang']) ? $this->parameters['lang'] : 'zh_CN'); |
| 140 | 140 | |
| 141 | - $response = $this->getHttpClient()->get($this->baseUrl . '/userinfo', [ |
|
| 141 | + $response = $this->getHttpClient()->get($this->baseUrl.'/userinfo', [ |
|
| 142 | 142 | 'query' => array_filter([ |
| 143 | 143 | 'access_token' => $token, |
| 144 | 144 | 'openid' => $this->openid, |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | ]; |
| 104 | 104 | |
| 105 | 105 | $response = $this->getHttpClient()->post( |
| 106 | - $this->getUserByCode . '?' . http_build_query($queryParams), |
|
| 106 | + $this->getUserByCode.'?'.http_build_query($queryParams), |
|
| 107 | 107 | [ |
| 108 | 108 | 'json' => ['tmp_auth_code' => $code], |
| 109 | 109 | ] |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $response = \json_decode($response->getBody()->getContents(), true); |
| 112 | 112 | |
| 113 | 113 | if (0 != $response['errcode']) { |
| 114 | - throw new \InvalidArgumentException('You get error: ' . json_encode($response, JSON_UNESCAPED_UNICODE)); |
|
| 114 | + throw new \InvalidArgumentException('You get error: '.json_encode($response, JSON_UNESCAPED_UNICODE)); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | return new User( |
@@ -18,12 +18,12 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | protected function getAuthUrl(): string |
| 20 | 20 | { |
| 21 | - return $this->buildAuthUrlFromBase('https://www.facebook.com/' . $this->version . '/dialog/oauth'); |
|
| 21 | + return $this->buildAuthUrlFromBase('https://www.facebook.com/'.$this->version.'/dialog/oauth'); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | protected function getTokenUrl(): string |
| 25 | 25 | { |
| 26 | - return $this->graphUrl . '/oauth/access_token'; |
|
| 26 | + return $this->graphUrl.'/oauth/access_token'; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | protected function getUserByToken(string $token, ?array $query = []): array |
| 55 | 55 | { |
| 56 | 56 | $appSecretProof = hash_hmac('sha256', $token, $this->getConfig()->get('client_secret')); |
| 57 | - $endpont = $this->graphUrl . '/' . $this->version . '/me?access_token=' . $token . '&appsecret_proof=' . $appSecretProof . '&fields=' . |
|
| 57 | + $endpont = $this->graphUrl.'/'.$this->version.'/me?access_token='.$token.'&appsecret_proof='.$appSecretProof.'&fields='. |
|
| 58 | 58 | implode(',', $this->fields); |
| 59 | 59 | |
| 60 | 60 | $response = $this->getHttpClient()->get( |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | protected function mapUserToObject(array $user): User |
| 73 | 73 | { |
| 74 | 74 | $userId = $user['id'] ?? null; |
| 75 | - $avatarUrl = $this->graphUrl . '/' . $this->version . '/' . $userId . '/picture'; |
|
| 75 | + $avatarUrl = $this->graphUrl.'/'.$this->version.'/'.$userId.'/picture'; |
|
| 76 | 76 | |
| 77 | 77 | $firstName = $user['first_name'] ?? null; |
| 78 | 78 | $lastName = $user['last_name'] ?? null; |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | [ |
| 82 | 82 | 'id' => $user['id'] ?? null, |
| 83 | 83 | 'nickname' => null, |
| 84 | - 'name' => $firstName . ' ' . $lastName, |
|
| 84 | + 'name' => $firstName.' '.$lastName, |
|
| 85 | 85 | 'email' => $user['email'] ?? null, |
| 86 | - 'avatar' => $userId ? $avatarUrl . '?type=normal' : null, |
|
| 87 | - 'avatar_original' => $userId ? $avatarUrl . '?width=1920' : null, |
|
| 86 | + 'avatar' => $userId ? $avatarUrl.'?type=normal' : null, |
|
| 87 | + 'avatar_original' => $userId ? $avatarUrl.'?width=1920' : null, |
|
| 88 | 88 | ] |
| 89 | 89 | ); |
| 90 | 90 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | protected function getAuthUrl(): string |
| 18 | 18 | { |
| 19 | - return $this->buildAuthUrlFromBase($this->baseUrl . 'authen/v1/index'); |
|
| 19 | + return $this->buildAuthUrlFromBase($this->baseUrl.'authen/v1/index'); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | protected function getCodeFields(): array |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | protected function getTokenUrl(): string |
| 31 | 31 | { |
| 32 | - return $this->baseUrl . 'authen/v1/access_token'; |
|
| 32 | + return $this->baseUrl.'authen/v1/access_token'; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -81,9 +81,9 @@ discard block |
||
| 81 | 81 | protected function getUserByToken(string $token): array |
| 82 | 82 | { |
| 83 | 83 | $response = $this->getHttpClient()->get( |
| 84 | - $this->baseUrl . '/authen/v1/user_info', |
|
| 84 | + $this->baseUrl.'/authen/v1/user_info', |
|
| 85 | 85 | [ |
| 86 | - 'headers' => ['Content-Type' => 'application/json', 'AuthoriBearer ' . $token], |
|
| 86 | + 'headers' => ['Content-Type' => 'application/json', 'AuthoriBearer '.$token], |
|
| 87 | 87 | 'query' => array_filter( |
| 88 | 88 | [ |
| 89 | 89 | 'user_access_token' => $token, |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $response = \json_decode($response->getBody(), true) ?? []; |
| 96 | 96 | |
| 97 | 97 | if (empty($response['data'])) { |
| 98 | - throw new \InvalidArgumentException('You have error! ' . json_encode($response, JSON_UNESCAPED_UNICODE)); |
|
| 98 | + throw new \InvalidArgumentException('You have error! '.json_encode($response, JSON_UNESCAPED_UNICODE)); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | return $response['data']; |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | { |
| 243 | 243 | $query = $this->getCodeFields() + ($this->state ? ['state' => $this->state] : []); |
| 244 | 244 | |
| 245 | - return $url . '?' . \http_build_query($query, '', '&', $this->encodingType); |
|
| 245 | + return $url.'?'.\http_build_query($query, '', '&', $this->encodingType); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | protected function getCodeFields(): array |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | if (empty($response[$this->accessTokenKey])) { |
| 286 | - throw new AuthorizeFailedException('Authorize Failed: ' . json_encode($response, JSON_UNESCAPED_UNICODE), $response); |
|
| 286 | + throw new AuthorizeFailedException('Authorize Failed: '.json_encode($response, JSON_UNESCAPED_UNICODE), $response); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | return $response + [ |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | protected function getAuthUrl(): string |
| 21 | 21 | { |
| 22 | - return $this->buildAuthUrlFromBase($this->baseUrl . '/platform/oauth/connect/'); |
|
| 22 | + return $this->buildAuthUrlFromBase($this->baseUrl.'/platform/oauth/connect/'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | protected function getTokenUrl(): string |
| 39 | 39 | { |
| 40 | - return $this->baseUrl . '/oauth/access_token/'; |
|
| 40 | + return $this->baseUrl.'/oauth/access_token/'; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | protected function getUserByToken(string $token): array |
| 93 | 93 | { |
| 94 | - $userUrl = $this->baseUrl . '/oauth/userinfo/'; |
|
| 94 | + $userUrl = $this->baseUrl.'/oauth/userinfo/'; |
|
| 95 | 95 | |
| 96 | 96 | if (empty($this->openId)) { |
| 97 | 97 | throw new InvalidArgumentException('please set open_id before your query.'); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | $response = \json_decode($response->getBody(), true) ?? []; |
| 138 | 138 | |
| 139 | 139 | if (($response['errcode'] ?? 1) > 0 || empty($response['UserId'])) { |
| 140 | - throw new AuthorizeFailedException('Failed to get user openid:' . $response['errmsg'] ?? 'Unknown.', $response); |
|
| 140 | + throw new AuthorizeFailedException('Failed to get user openid:'.$response['errmsg'] ?? 'Unknown.', $response); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | return $response; |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | $response = \json_decode($response->getBody(), true) ?? []; |
| 165 | 165 | |
| 166 | 166 | if (($response['errcode'] ?? 1) > 0 || empty($response['userid'])) { |
| 167 | - throw new AuthorizeFailedException('Failed to get user:' . $response['errmsg'] ?? 'Unknown.', $response); |
|
| 167 | + throw new AuthorizeFailedException('Failed to get user:'.$response['errmsg'] ?? 'Unknown.', $response); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | return \json_decode($response->getBody(), true) ?? []; |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | $response = \json_decode($response->getBody(), true) ?? []; |
| 217 | 217 | |
| 218 | 218 | if (($response['errcode'] ?? 1) > 0) { |
| 219 | - throw new AuthorizeFailedException('Failed to get api access_token:' . $response['errmsg'] ?? 'Unknown.', $response); |
|
| 219 | + throw new AuthorizeFailedException('Failed to get api access_token:'.$response['errmsg'] ?? 'Unknown.', $response); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | return $response['access_token']; |
@@ -97,11 +97,11 @@ |
||
| 97 | 97 | $name = $firstName.' '.$lastName; |
| 98 | 98 | |
| 99 | 99 | $images = $user['profilePicture.displayImage~.elements'] ?? []; |
| 100 | - $avatars = array_filter($images, function ($image) { |
|
| 100 | + $avatars = array_filter($images, function($image) { |
|
| 101 | 101 | return $image['data']['com.linkedin.digitalmedia.mediaartifact.StillImage']['storageSize']['width'] === 100; |
| 102 | 102 | }); |
| 103 | 103 | $avatar = array_shift($avatars); |
| 104 | - $originalAvatars = array_filter($images, function ($image) { |
|
| 104 | + $originalAvatars = array_filter($images, function($image) { |
|
| 105 | 105 | return $image['data']['com.linkedin.digitalmedia.mediaartifact.StillImage']['storageSize']['width'] === 800; |
| 106 | 106 | }); |
| 107 | 107 | $originalAvatar = array_shift($originalAvatars); |