Passed
Push — master ( f9a48a...945dc8 )
by Mike
03:01
created
src/Response/File.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     protected $destinationPath;
23 23
 
24 24
     public function __construct($curlRequest, $curlResponse = NULL, $destination = NULL){
25
-        parent::__construct($curlRequest,$curlResponse);
25
+        parent::__construct($curlRequest, $curlResponse);
26 26
         $this->setDestinationPath($destination);
27 27
     }
28 28
 
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
      * Extract Filename from Headers
32 32
      * @param mixed $curlResponse
33 33
      */
34
-    public function setCurlResponse($curlResponse) {
34
+    public function setCurlResponse($curlResponse){
35 35
         parent::setCurlResponse($curlResponse);
36
-        if (!$this->error) {
37
-            if (empty($this->fileName)) {
36
+        if (!$this->error){
37
+            if (empty($this->fileName)){
38 38
                 $this->extractFileName();
39 39
             }
40 40
             $this->writeFile();
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
                 mkdir($this->destinationPath, 0777);
96 96
             }
97 97
             $file = $this->file();
98
-            $fileHandle = fopen($file,'w+');
99
-            fwrite($fileHandle,$this->body);
98
+            $fileHandle = fopen($file, 'w+');
99
+            fwrite($fileHandle, $this->body);
100 100
             fclose($fileHandle);
101 101
             return $file;
102 102
         }else{
Please login to merge, or discard this patch.
Braces   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
      * Extract Filename from Headers
32 32
      * @param mixed $curlResponse
33 33
      */
34
-    public function setCurlResponse($curlResponse) {
34
+    public function setCurlResponse($curlResponse){
35 35
         parent::setCurlResponse($curlResponse);
36
-        if (!$this->error) {
37
-            if (empty($this->fileName)) {
36
+        if (!$this->error){
37
+            if (empty($this->fileName)){
38 38
                 $this->extractFileName();
39 39
             }
40 40
             $this->writeFile();
@@ -59,8 +59,7 @@  discard block
 block discarded – undo
59 59
      * Extract the filename from the Headers, and store it in filename property
60 60
      */
61 61
     protected function extractFileName(){
62
-        foreach (explode("\r\n", $this->headers) as $header)
63
-        {
62
+        foreach (explode("\r\n", $this->headers) as $header){
64 63
             if (strpos($header, 'filename')!==FALSE){
65 64
                 $this->setFileName(substr($header, (strpos($header, "\"")+1), -1));
66 65
             }
@@ -99,7 +98,7 @@  discard block
 block discarded – undo
99 98
             fwrite($fileHandle,$this->body);
100 99
             fclose($fileHandle);
101 100
             return $file;
102
-        }else{
101
+        } else{
103 102
             return FALSE;
104 103
         }
105 104
     }
Please login to merge, or discard this patch.
src/Response/Abstracts/AbstractResponse.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,14 +45,14 @@  discard block
 block discarded – undo
45 45
      */
46 46
     protected $info;
47 47
 
48
-    public function __construct($curlRequest,$curlResponse = NULL){
48
+    public function __construct($curlRequest, $curlResponse = NULL){
49 49
         $this->CurlRequest = $curlRequest;
50 50
         if ($curlResponse!==NULL){
51 51
             $this->setCurlResponse($curlResponse);
52 52
         }
53 53
     }
54 54
 
55
-    public function setCurlResponse($curlResponse) {
55
+    public function setCurlResponse($curlResponse){
56 56
         $this->extractInfo();
57 57
         if (!$this->getError()){
58 58
             $this->extractResponse($curlResponse);
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     protected function extractInfo(){
67 67
         $this->info = curl_getinfo($this->CurlRequest);
68 68
         $this->status = $this->info['http_code'];
69
-        if (curl_errno($this->CurlRequest)!== CURLE_OK){
69
+        if (curl_errno($this->CurlRequest)!==CURLE_OK){
70 70
             $this->error = curl_error($this->CurlRequest);
71 71
         }
72 72
         $this->error = FALSE;
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
         }
53 53
     }
54 54
 
55
-    public function setCurlResponse($curlResponse) {
55
+    public function setCurlResponse($curlResponse){
56 56
         $this->extractInfo();
57 57
         if (!$this->getError()){
58 58
             $this->extractResponse($curlResponse);
Please login to merge, or discard this patch.
src/Client/Abstracts/AbstractClient.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      */
64 64
     protected $entryPoints = array();
65 65
 
66
-    public function __construct($server = '',array $credentials = array()){
66
+    public function __construct($server = '', array $credentials = array()){
67 67
         $server = (empty($server)?$this->server:$server);
68 68
         $this->setServer($server);
69 69
         $credentials = (empty($credentials)?$this->credentials:$credentials);
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      * @inheritdoc
76 76
      * @param string $server
77 77
      */
78
-    public function setServer($server) {
78
+    public function setServer($server){
79 79
         $this->server = $server;
80 80
         $this->apiURL = Helpers::configureAPIURL($this->server);
81 81
         return $this;
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     /**
85 85
      * @inheritdoc
86 86
      */
87
-    public function getAPIUrl() {
87
+    public function getAPIUrl(){
88 88
         return $this->apiURL;
89 89
     }
90 90
 
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
      */
95 95
     public function setCredentials(array $credentials){
96 96
         $this->credentials = $credentials;
97
-        if (isset($this->credentials['client_id'])) {
97
+        if (isset($this->credentials['client_id'])){
98 98
             $token = static::getStoredToken($this->credentials['client_id']);
99
-            if (!empty($token)) {
99
+            if (!empty($token)){
100 100
                 $this->setToken($token);
101 101
             }
102 102
         }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
     /**
130 130
      * @inheritdoc
131 131
      */
132
-    public function getServer() {
132
+    public function getServer(){
133 133
         return $this->server;
134 134
     }
135 135
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
      * @inheritdoc
138 138
      */
139 139
     public function authenticated(){
140
-        return time() < $this->expiration;
140
+        return time()<$this->expiration;
141 141
     }
142 142
 
143 143
     /**
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
      */
160 160
     public function registerEntryPoint($funcName, $className){
161 161
         $implements = class_implements($className);
162
-        if (is_array($implements) && in_array('SugarAPI\SDK\EntryPoint\Interfaces\EPInterface',$implements)){
162
+        if (is_array($implements) && in_array('SugarAPI\SDK\EntryPoint\Interfaces\EPInterface', $implements)){
163 163
             $this->entryPoints[$funcName] = $className;
164 164
         }else{
165
-            throw new EntryPointException($className,'Class must extend SugarAPI\SDK\EntryPoint\Interfaces\EPInterface');
165
+            throw new EntryPointException($className, 'Class must extend SugarAPI\SDK\EntryPoint\Interfaces\EPInterface');
166 166
         }
167 167
         return $this;
168 168
     }
@@ -180,13 +180,13 @@  discard block
 block discarded – undo
180 180
             $EntryPoint = new $Class($this->apiURL, $params);
181 181
 
182 182
             if ($EntryPoint->authRequired()){
183
-                if (isset($this->token) && $this->authenticated()) {
183
+                if (isset($this->token) && $this->authenticated()){
184 184
                     $EntryPoint->setAuth($this->getToken()->access_token);
185 185
                 }
186 186
             }
187 187
             return $EntryPoint;
188 188
         }else{
189
-            throw new EntryPointException($name,'Unregistered EntryPoint');
189
+            throw new EntryPointException($name, 'Unregistered EntryPoint');
190 190
         }
191 191
     }
192 192
 
@@ -194,13 +194,13 @@  discard block
 block discarded – undo
194 194
      * @inheritdoc
195 195
      * @throws AuthenticationException - When Login request fails
196 196
      */
197
-    public function login() {
197
+    public function login(){
198 198
         $EP = new OAuth2Token($this->apiURL);
199 199
         $response = $EP->execute($this->credentials)->getResponse();
200 200
         if ($response->getStatus()=='200'){
201 201
             $this->setToken($response->getBody(FALSE));
202
-            static::storeToken($this->token,$this->credentials['client_id']);
203
-        } else {
202
+            static::storeToken($this->token, $this->credentials['client_id']);
203
+        }else{
204 204
             $error = $response->getBody();
205 205
             throw new AuthenticationException("Login Response [".$error['error']."] ".$error['error_message']);
206 206
         }
@@ -212,9 +212,9 @@  discard block
 block discarded – undo
212 212
      * @throws AuthenticationException - When Refresh Request fails
213 213
      */
214 214
     public function refreshToken(){
215
-        if (isset($this->credentials['client_id'])&&
216
-            isset($this->credentials['client_secret'])&&
217
-            isset($this->token)) {
215
+        if (isset($this->credentials['client_id']) &&
216
+            isset($this->credentials['client_secret']) &&
217
+            isset($this->token)){
218 218
             $refreshOptions = array(
219 219
                 'client_id' => $this->credentials['client_id'],
220 220
                 'client_secret' => $this->credentials['client_secret'],
@@ -222,13 +222,13 @@  discard block
 block discarded – undo
222 222
             );
223 223
             $EP = new RefreshToken($this->apiURL);
224 224
             $response = $EP->execute($refreshOptions)->getResponse();
225
-            if ($response->getStatus() == '200') {
225
+            if ($response->getStatus()=='200'){
226 226
                 $this->setToken($response->getBody(FALSE));
227 227
                 static::storeToken($this->token, $this->credentials['client_id']);
228 228
                 return TRUE;
229
-            } else {
229
+            }else{
230 230
                 $error = $response->getBody();
231
-                throw new AuthenticationException("Refresh Response [" . $error['error'] . "] " . $error['error_message']);
231
+                throw new AuthenticationException("Refresh Response [".$error['error']."] ".$error['error_message']);
232 232
             }
233 233
         }
234 234
         return FALSE;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
      * @inheritdoc
259 259
      * @param \stdClass $token
260 260
      */
261
-    public static function storeToken($token, $client_id) {
261
+    public static function storeToken($token, $client_id){
262 262
         static::$_STORED_TOKENS[$client_id] = $token;
263 263
         return TRUE;
264 264
     }
@@ -266,14 +266,14 @@  discard block
 block discarded – undo
266 266
     /**
267 267
      * @inheritdoc
268 268
      */
269
-    public static function getStoredToken($client_id) {
269
+    public static function getStoredToken($client_id){
270 270
         return (isset(static::$_STORED_TOKENS[$client_id])?static::$_STORED_TOKENS[$client_id]:NULL);
271 271
     }
272 272
 
273 273
     /**
274 274
      * @inheritdoc
275 275
      */
276
-    public static function removeStoredToken($client_id) {
276
+    public static function removeStoredToken($client_id){
277 277
         unset(static::$_STORED_TOKENS[$client_id]);
278 278
         return TRUE;
279 279
     }
Please login to merge, or discard this patch.
Braces   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      * @inheritdoc
76 76
      * @param string $server
77 77
      */
78
-    public function setServer($server) {
78
+    public function setServer($server){
79 79
         $this->server = $server;
80 80
         $this->apiURL = Helpers::configureAPIURL($this->server);
81 81
         return $this;
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     /**
85 85
      * @inheritdoc
86 86
      */
87
-    public function getAPIUrl() {
87
+    public function getAPIUrl(){
88 88
         return $this->apiURL;
89 89
     }
90 90
 
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
      */
95 95
     public function setCredentials(array $credentials){
96 96
         $this->credentials = $credentials;
97
-        if (isset($this->credentials['client_id'])) {
97
+        if (isset($this->credentials['client_id'])){
98 98
             $token = static::getStoredToken($this->credentials['client_id']);
99
-            if (!empty($token)) {
99
+            if (!empty($token)){
100 100
                 $this->setToken($token);
101 101
             }
102 102
         }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
     /**
130 130
      * @inheritdoc
131 131
      */
132
-    public function getServer() {
132
+    public function getServer(){
133 133
         return $this->server;
134 134
     }
135 135
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
         $implements = class_implements($className);
162 162
         if (is_array($implements) && in_array('SugarAPI\SDK\EntryPoint\Interfaces\EPInterface',$implements)){
163 163
             $this->entryPoints[$funcName] = $className;
164
-        }else{
164
+        } else{
165 165
             throw new EntryPointException($className,'Class must extend SugarAPI\SDK\EntryPoint\Interfaces\EPInterface');
166 166
         }
167 167
         return $this;
@@ -180,12 +180,12 @@  discard block
 block discarded – undo
180 180
             $EntryPoint = new $Class($this->apiURL, $params);
181 181
 
182 182
             if ($EntryPoint->authRequired()){
183
-                if (isset($this->token) && $this->authenticated()) {
183
+                if (isset($this->token) && $this->authenticated()){
184 184
                     $EntryPoint->setAuth($this->getToken()->access_token);
185 185
                 }
186 186
             }
187 187
             return $EntryPoint;
188
-        }else{
188
+        } else{
189 189
             throw new EntryPointException($name,'Unregistered EntryPoint');
190 190
         }
191 191
     }
@@ -194,13 +194,13 @@  discard block
 block discarded – undo
194 194
      * @inheritdoc
195 195
      * @throws AuthenticationException - When Login request fails
196 196
      */
197
-    public function login() {
197
+    public function login(){
198 198
         $EP = new OAuth2Token($this->apiURL);
199 199
         $response = $EP->execute($this->credentials)->getResponse();
200 200
         if ($response->getStatus()=='200'){
201 201
             $this->setToken($response->getBody(FALSE));
202 202
             static::storeToken($this->token,$this->credentials['client_id']);
203
-        } else {
203
+        } else{
204 204
             $error = $response->getBody();
205 205
             throw new AuthenticationException("Login Response [".$error['error']."] ".$error['error_message']);
206 206
         }
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
     public function refreshToken(){
215 215
         if (isset($this->credentials['client_id'])&&
216 216
             isset($this->credentials['client_secret'])&&
217
-            isset($this->token)) {
217
+            isset($this->token)){
218 218
             $refreshOptions = array(
219 219
                 'client_id' => $this->credentials['client_id'],
220 220
                 'client_secret' => $this->credentials['client_secret'],
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
             );
223 223
             $EP = new RefreshToken($this->apiURL);
224 224
             $response = $EP->execute($refreshOptions)->getResponse();
225
-            if ($response->getStatus() == '200') {
225
+            if ($response->getStatus() == '200'){
226 226
                 $this->setToken($response->getBody(FALSE));
227 227
                 static::storeToken($this->token, $this->credentials['client_id']);
228 228
                 return TRUE;
229
-            } else {
229
+            } else{
230 230
                 $error = $response->getBody();
231 231
                 throw new AuthenticationException("Refresh Response [" . $error['error'] . "] " . $error['error_message']);
232 232
             }
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
                 unset($this->token);
247 247
                 static::removeStoredToken($this->credentials['client_id']);
248 248
                 return TRUE;
249
-            }else{
249
+            } else{
250 250
                 $error = $response->getBody();
251 251
                 throw new AuthenticationException("Logout Response [".$error['error']."] ".$error['message']);
252 252
             }
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
      * @inheritdoc
259 259
      * @param \stdClass $token
260 260
      */
261
-    public static function storeToken($token, $client_id) {
261
+    public static function storeToken($token, $client_id){
262 262
         static::$_STORED_TOKENS[$client_id] = $token;
263 263
         return TRUE;
264 264
     }
@@ -266,14 +266,14 @@  discard block
 block discarded – undo
266 266
     /**
267 267
      * @inheritdoc
268 268
      */
269
-    public static function getStoredToken($client_id) {
269
+    public static function getStoredToken($client_id){
270 270
         return (isset(static::$_STORED_TOKENS[$client_id])?static::$_STORED_TOKENS[$client_id]:NULL);
271 271
     }
272 272
 
273 273
     /**
274 274
      * @inheritdoc
275 275
      */
276
-    public static function removeStoredToken($client_id) {
276
+    public static function removeStoredToken($client_id){
277 277
         unset(static::$_STORED_TOKENS[$client_id]);
278 278
         return TRUE;
279 279
     }
Please login to merge, or discard this patch.
src/EntryPoint/Abstracts/GET/AbstractGetFileEntryPoint.php 1 patch
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
      * The directory in which to download the File
13 13
      * @var string
14 14
      */
15
-    protected $downloadDir = null;
15
+    protected $downloadDir = NULL;
16 16
 
17 17
     /**
18 18
      * @inheritdoc
Please login to merge, or discard this patch.
src/EntryPoint/Abstracts/GET/AbstractGetEntryPoint.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 
12 12
 abstract class AbstractGetEntryPoint extends AbstractEntryPoint {
13 13
 
14
-    public function __construct($url, array $options = array()) {
14
+    public function __construct($url, array $options = array()){
15 15
         $this->setRequest(new GET());
16 16
         $this->setResponse(new JSON($this->Request->getCurlObject()));
17 17
         parent::__construct($url, $options);
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 
12 12
 abstract class AbstractGetEntryPoint extends AbstractEntryPoint {
13 13
 
14
-    public function __construct($url, array $options = array()) {
14
+    public function __construct($url, array $options = array()){
15 15
         $this->setRequest(new GET());
16 16
         $this->setResponse(new JSON($this->Request->getCurlObject()));
17 17
         parent::__construct($url, $options);
Please login to merge, or discard this patch.
src/EntryPoint/Abstracts/POST/AbstractPostEntryPoint.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 
12 12
 abstract class AbstractPostEntryPoint extends AbstractEntryPoint {
13 13
 
14
-    public function __construct($url, array $options = array()) {
14
+    public function __construct($url, array $options = array()){
15 15
         $this->setRequest(new POST());
16 16
         $this->setResponse(new JSON($this->Request->getCurlObject()));
17 17
         parent::__construct($url, $options);
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 
12 12
 abstract class AbstractPostEntryPoint extends AbstractEntryPoint {
13 13
 
14
-    public function __construct($url, array $options = array()) {
14
+    public function __construct($url, array $options = array()){
15 15
         $this->setRequest(new POST());
16 16
         $this->setResponse(new JSON($this->Request->getCurlObject()));
17 17
         parent::__construct($url, $options);
Please login to merge, or discard this patch.
src/EntryPoint/Abstracts/DELETE/AbstractDeleteEntryPoint.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 
12 12
 abstract class AbstractDeleteEntryPoint extends AbstractEntryPoint {
13 13
 
14
-    public function __construct($url, array $options = array()) {
14
+    public function __construct($url, array $options = array()){
15 15
         $this->setRequest(new DELETE());
16 16
         $this->setResponse(new JSON($this->getRequest()->getCurlObject()));
17 17
         parent::__construct($url, $options);
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 
12 12
 abstract class AbstractDeleteEntryPoint extends AbstractEntryPoint {
13 13
 
14
-    public function __construct($url, array $options = array()) {
14
+    public function __construct($url, array $options = array()){
15 15
         $this->setRequest(new DELETE());
16 16
         $this->setResponse(new JSON($this->getRequest()->getCurlObject()));
17 17
         parent::__construct($url, $options);
Please login to merge, or discard this patch.
src/EntryPoint/Abstracts/PUT/AbstractPutEntryPoint.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 
12 12
 abstract class AbstractPutEntryPoint extends AbstractEntryPoint {
13 13
 
14
-    public function __construct($url, array $options = array()) {
14
+    public function __construct($url, array $options = array()){
15 15
         $this->setRequest(new PUT());
16 16
         $this->setResponse(new JSON($this->Request->getCurlObject()));
17 17
         parent::__construct($url, $options);
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 
12 12
 abstract class AbstractPutEntryPoint extends AbstractEntryPoint {
13 13
 
14
-    public function __construct($url, array $options = array()) {
14
+    public function __construct($url, array $options = array()){
15 15
         $this->setRequest(new PUT());
16 16
         $this->setResponse(new JSON($this->Request->getCurlObject()));
17 17
         parent::__construct($url, $options);
Please login to merge, or discard this patch.