Passed
Pull Request — master (#417)
by
unknown
01:41
created
src/Picqer/Financials/Exact/Connection.php 3 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -186,49 +186,49 @@
 block discarded – undo
186 186
         }
187 187
 
188 188
         // If access token is not set or token has expired, acquire new token
189
-		if (empty($this->accessToken)){
190
-			$this->acquireAccessToken();
191
-		}else if($this->tokenHasExpired()){
192
-			$this->acquireAccessToken_by_refreshtoken();
193
-		}
189
+        if (empty($this->accessToken)){
190
+            $this->acquireAccessToken();
191
+        }else if($this->tokenHasExpired()){
192
+            $this->acquireAccessToken_by_refreshtoken();
193
+        }
194 194
 		
195 195
         $client = $this->client();
196 196
 
197 197
         return $client;
198 198
     }
199 199
 	
200
-	// Acquire AccessToken by RefreshToken
201
-	private function acquireAccessToken_by_refreshtoken() {
202
-		$headers = array("Content-Type: application/x-www-form-urlencoded", "Cache-Control: no-cache");	
203
-		$params = array(
204
-			'refresh_token' => $this->refreshToken,
205
-			'grant_type' => 'refresh_token',
206
-			'client_id'     => $this->exactClientId,
200
+    // Acquire AccessToken by RefreshToken
201
+    private function acquireAccessToken_by_refreshtoken() {
202
+        $headers = array("Content-Type: application/x-www-form-urlencoded", "Cache-Control: no-cache");	
203
+        $params = array(
204
+            'refresh_token' => $this->refreshToken,
205
+            'grant_type' => 'refresh_token',
206
+            'client_id'     => $this->exactClientId,
207 207
             'client_secret' => $this->exactClientSecret,
208
-		);
209
-
210
-		$curl = curl_init();                  
211
-		$url = $this->getTokenUrl();
212
-		curl_setopt($curl, CURLOPT_URL,$url);
213
-		curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);				
214
-		curl_setopt($curl, CURLOPT_POST, true); 
215
-		curl_setopt($curl, CURLOPT_POSTFIELDS,http_build_query($params));
216
-		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
217
-		$output = curl_exec ($curl);
218
-
219
-		$res = json_decode($output, true);
220
-		if(!$res['error'] && $res['refresh_token']){
221
-			$this->accessToken = $res['access_token'];
222
-			$this->refreshToken = $res['refresh_token'];
223
-			$this->tokenExpires = $this->getTimestampFromExpiresIn($res['expires_in']);
224
-
225
-			if (is_callable($this->tokenUpdateCallback)) {
226
-				call_user_func($this->tokenUpdateCallback, $this);
227
-			}
228
-		} else {
229
-			throw new ApiException('Could not acquire tokens, json decode failed. Got response: ' . $res["error"] .', '. $res["error_description"]);
230
-		}
231
-	}
208
+        );
209
+
210
+        $curl = curl_init();                  
211
+        $url = $this->getTokenUrl();
212
+        curl_setopt($curl, CURLOPT_URL,$url);
213
+        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);				
214
+        curl_setopt($curl, CURLOPT_POST, true); 
215
+        curl_setopt($curl, CURLOPT_POSTFIELDS,http_build_query($params));
216
+        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
217
+        $output = curl_exec ($curl);
218
+
219
+        $res = json_decode($output, true);
220
+        if(!$res['error'] && $res['refresh_token']){
221
+            $this->accessToken = $res['access_token'];
222
+            $this->refreshToken = $res['refresh_token'];
223
+            $this->tokenExpires = $this->getTimestampFromExpiresIn($res['expires_in']);
224
+
225
+            if (is_callable($this->tokenUpdateCallback)) {
226
+                call_user_func($this->tokenUpdateCallback, $this);
227
+            }
228
+        } else {
229
+            throw new ApiException('Could not acquire tokens, json decode failed. Got response: ' . $res["error"] .', '. $res["error_description"]);
230
+        }
231
+    }
232 232
 
233 233
     /**
234 234
      * @param string $method
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
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->acquireAccessToken_by_refreshtoken();
193 193
 		}
194 194
 		
@@ -209,15 +209,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -188,7 +188,7 @@
 block discarded – undo
188 188
         // If access token is not set or token has expired, acquire new token
189 189
 		if (empty($this->accessToken)){
190 190
 			$this->acquireAccessToken();
191
-		}else if($this->tokenHasExpired()){
191
+		} else if($this->tokenHasExpired()){
192 192
 			$this->acquireAccessToken_by_refreshtoken();
193 193
 		}
194 194
 		
Please login to merge, or discard this patch.