@@ -186,9 +186,9 @@ discard block |
||
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | // If access token is not set or token has expired, acquire new token |
| 189 | - if (empty($this->accessToken)){ |
|
| 189 | + if (empty($this->accessToken)) { |
|
| 190 | 190 | $this->acquireAccessToken(); |
| 191 | - }else if($this->tokenHasExpired()){ |
|
| 191 | + } else if ($this->tokenHasExpired()) { |
|
| 192 | 192 | $this->aquire_accesstoken_by_refreshtoken(); |
| 193 | 193 | } |
| 194 | 194 | |
@@ -209,15 +209,15 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | $curl = curl_init(); |
| 211 | 211 | $url = $this->getTokenUrl(); |
| 212 | - curl_setopt($curl, CURLOPT_URL,$url); |
|
| 212 | + curl_setopt($curl, CURLOPT_URL, $url); |
|
| 213 | 213 | curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); |
| 214 | 214 | curl_setopt($curl, CURLOPT_POST, true); |
| 215 | - curl_setopt($curl, CURLOPT_POSTFIELDS,http_build_query($params)); |
|
| 215 | + curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params)); |
|
| 216 | 216 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
| 217 | - $output = curl_exec ($curl); |
|
| 217 | + $output = curl_exec($curl); |
|
| 218 | 218 | |
| 219 | 219 | $res = json_decode($output, true); |
| 220 | - if(!$res['error'] && $res['refresh_token']){ |
|
| 220 | + if ( ! $res['error'] && $res['refresh_token']) { |
|
| 221 | 221 | $this->accessToken = $res['access_token']; |
| 222 | 222 | $this->refreshToken = $res['refresh_token']; |
| 223 | 223 | $this->tokenExpires = $this->getTimestampFromExpiresIn($res['expires_in']); |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | call_user_func($this->tokenUpdateCallback, $this); |
| 227 | 227 | } |
| 228 | 228 | } else { |
| 229 | - throw new ApiException('Could not acquire tokens, json decode failed. Got response: ' . $res["error"] .', '. $res["error_description"]); |
|
| 229 | + throw new ApiException('Could not acquire tokens, json decode failed. Got response: ' . $res["error"] . ', ' . $res["error_description"]); |
|
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | |
@@ -254,12 +254,12 @@ discard block |
||
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | // If we have a token, sign the request |
| 257 | - if (! $this->needsAuthentication() && ! empty($this->accessToken)) { |
|
| 257 | + if ( ! $this->needsAuthentication() && ! empty($this->accessToken)) { |
|
| 258 | 258 | $headers['Authorization'] = 'Bearer ' . $this->accessToken; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | // Create param string |
| 262 | - if (! empty($params)) { |
|
| 262 | + if ( ! empty($params)) { |
|
| 263 | 263 | $endpoint .= '?' . http_build_query($params); |
| 264 | 264 | } |
| 265 | 265 | |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | */ |
| 571 | 571 | private function getTimestampFromExpiresIn($expiresIn) |
| 572 | 572 | { |
| 573 | - if (! ctype_digit($expiresIn)) { |
|
| 573 | + if ( ! ctype_digit($expiresIn)) { |
|
| 574 | 574 | throw new \InvalidArgumentException('Function requires a numeric expires value'); |
| 575 | 575 | } |
| 576 | 576 | |
@@ -671,7 +671,7 @@ discard block |
||
| 671 | 671 | */ |
| 672 | 672 | private function parseExceptionForErrorMessages(Exception $e) |
| 673 | 673 | { |
| 674 | - if (! $e instanceof BadResponseException) { |
|
| 674 | + if ( ! $e instanceof BadResponseException) { |
|
| 675 | 675 | throw new ApiException($e->getMessage(), 0, $e); |
| 676 | 676 | } |
| 677 | 677 | |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | $responseBody = $response->getBody()->getContents(); |
| 684 | 684 | $decodedResponseBody = json_decode($responseBody, true); |
| 685 | 685 | |
| 686 | - if (! is_null($decodedResponseBody) && isset($decodedResponseBody['error']['message']['value'])) { |
|
| 686 | + if ( ! is_null($decodedResponseBody) && isset($decodedResponseBody['error']['message']['value'])) { |
|
| 687 | 687 | $errorMessage = $decodedResponseBody['error']['message']['value']; |
| 688 | 688 | } else { |
| 689 | 689 | $errorMessage = $responseBody; |