Passed
Push — master ( 635200...ad05d4 )
by Vince
03:32 queued 01:55
created
src/core/user/userLoad.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 
100 100
         $this->secret = $this->getDefaults()['config']['MASTER_KEY'];
101 101
 
102
-        if( isset($options['secret']) && $options['secret'] == 'append' ) {
102
+        if (isset($options['secret']) && $options['secret'] == 'append') {
103 103
             $this->secretAppend = true;
104 104
         }
105 105
     }
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
                 \PDO::FETCH_OBJ
139 139
             );
140 140
 
141
-        if( $this->secretAppend ) {
141
+        if ($this->secretAppend) {
142 142
             $this->secret = $account->secret;
143 143
         }
144 144
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
                 $headers->setOptions($this->getOptions());
154 154
                 $sentToken = $headers->hasBearerToken();
155 155
 
156
-                if( $sentToken ) {
156
+                if ($sentToken) {
157 157
                     /**
158 158
                      * [$jwt Decode the JWT]
159 159
                      * @var auth\jwt
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
                     ;
172 172
                     $absSeconds = ($decoded['exp'] - ($this->timeNow() - $leeway));
173 173
 
174
-                    if( $absSeconds > 0 ) {
174
+                    if ($absSeconds > 0) {
175 175
                         $account->JWT = $sentToken;
176 176
                     }
177 177
 
@@ -215,21 +215,21 @@  discard block
 block discarded – undo
215 215
     public function refreshTokenGenerate($account)
216 216
     {
217 217
         $offset = 86400;
218
-        $time = ($this->timeNow()+$offset);
218
+        $time = ($this->timeNow() + $offset);
219 219
 
220
-        if( isset($account->refresh_token) && !empty($account->refresh_token) ) {
220
+        if (isset($account->refresh_token) && !empty($account->refresh_token)) {
221 221
             $raToken = explode('.', $account->refresh_token);
222
-            if( !empty($raToken) ) {
222
+            if (!empty($raToken)) {
223 223
                 $raToken = array_values(array_filter($raToken));
224
-                $time = ($raToken[0] <= ($this->timeNow()-$offset) ) ? ($this->timeNow()+$offset) : $raToken[0];
224
+                $time = ($raToken[0] <= ($this->timeNow() - $offset)) ? ($this->timeNow() + $offset) : $raToken[0];
225 225
             }
226 226
         }
227 227
 
228 228
         $cipher = new encoder\cipher;
229
-        $refreshHash = $account->account_id.':'.$account->secret;
229
+        $refreshHash = $account->account_id . ':' . $account->secret;
230 230
         $refreshHash = $cipher->encode($cipher->hash('sha256', $refreshHash, $account->secret));
231 231
 
232
-        $refreshHash = $time.'.'.$refreshHash;
232
+        $refreshHash = $time . '.' . $refreshHash;
233 233
         $account->refreshToken = $refreshHash;
234 234
 
235 235
         $updateProp = [
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
         /**
302 302
          * Check token expiry
303 303
          */
304
-        if($this->checkVal($userPayload['payload'], 'exp') && !$skipExpiry) {
304
+        if ($this->checkVal($userPayload['payload'], 'exp') && !$skipExpiry) {
305 305
             return $this->refreshJWT($userPayload);
306 306
         }
307 307
 
@@ -365,26 +365,26 @@  discard block
 block discarded – undo
365 365
                 $payload['iat'] = $iat;
366 366
             }
367 367
             if (false !== ($nbf = $this->checkVal($jwtOptions, 'notBeFor'))) {
368
-                if( strtolower($nbf) == 'issuedat' && isset($payload['iat']) ) {
368
+                if (strtolower($nbf) == 'issuedat' && isset($payload['iat'])) {
369 369
                     $nbf = $payload['iat'] + 10;
370 370
                 }
371 371
                 $payload['nbf'] = $nbf;
372 372
             }
373 373
         }
374 374
 
375
-        if( $refresh && $exp ) {
375
+        if ($refresh && $exp) {
376 376
             $refreshPayload = $payload;
377 377
 
378 378
             $offset = $exp - $this->timeNow();
379 379
             $leeway = ($this->checkVal($this->options['jwt'], 'leeway')) ?: $this->jwt->getLeeway();
380 380
 
381
-            $refreshPayload['exp'] = $exp+$offset+$leeway;
381
+            $refreshPayload['exp'] = $exp + $offset + $leeway;
382 382
 
383 383
             $refreshJWT = $this->refreshJWT([
384 384
                 'payload' => $refreshPayload
385 385
             ]);
386 386
 
387
-            if( isset($refreshJWT['refresh']) ) {
387
+            if (isset($refreshJWT['refresh'])) {
388 388
                 return $refreshJWT['refresh'];
389 389
             }
390 390
         }
Please login to merge, or discard this patch.
src/core/throttle/limiter.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
             $bucket->getTokenData()
212 212
         );
213 213
 
214
-        if($this->isMockTest) {
214
+        if ($this->isMockTest) {
215 215
             return;
216 216
         }
217 217
         
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
      */
258 258
     public function getAccount()
259 259
     {
260
-        if($this->isMockTest) {
260
+        if ($this->isMockTest) {
261 261
             $this->getMockAccount();
262 262
         }
263 263
 
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 
282 282
         $mockAccount = [];
283 283
 
284
-        if(!isset($mockAccount['bucket'])) {
284
+        if (!isset($mockAccount['bucket'])) {
285 285
             $mockAccount['bucket'] = $packer->pack(
286 286
                 $bucket->getTokenData()
287 287
             );
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 
290 290
         $mockAccount['access'] = time();
291 291
 
292
-        $this->setAccount((object)$mockAccount);
293
-        $this->mockAccount = (object)$mockAccount;
292
+        $this->setAccount((object) $mockAccount);
293
+        $this->mockAccount = (object) $mockAccount;
294 294
     }
295 295
 
296 296
     /**
Please login to merge, or discard this patch.
src/core/server.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             $this->header = new headers\header;
154 154
             $this->header->setOptions($options);
155 155
 
156
-            if (empty((array)$this->header->getMethod())) {
156
+            if (empty((array) $this->header->getMethod())) {
157 157
                 $this->header->requestMethod();
158 158
             }
159 159
         }
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
      * [getOptions Get the stored Responsible API options]
207 207
      * @return array|null
208 208
      */
209
-    public function getOptions():?array
209
+    public function getOptions(): ?array
210 210
     {
211 211
         return $this->options;
212 212
     }
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
         }
264 264
 
265 265
         if (is_null($key) || $key == '') {
266
-            if( !is_null($response) ) {
266
+            if (!is_null($response)) {
267 267
                 $this->RESPONSE['response'] = $response;
268 268
             }
269 269
             $this->RESPONSE = array_merge($responseHeader, $this->RESPONSE);
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
      */
281 281
     public function getResponse()
282 282
     {
283
-        if(isset($this->RESPONSE['response']['response'])) {
283
+        if (isset($this->RESPONSE['response']['response'])) {
284 284
             $this->RESPONSE['response'] = $this->RESPONSE['response']['response'];
285 285
         }
286 286
         return $this->RESPONSE;
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
     public function authenticate()
311 311
     {
312 312
         $options = $this->getOptions();
313
-        $route = (isset($options['route']) && !empty($options['route']) ) ? $options['route'] : '';
313
+        $route = (isset($options['route']) && !empty($options['route'])) ? $options['route'] : '';
314 314
 
315 315
         $this->endpoints->baseApiRoot(dirname(__DIR__));
316 316
         $this->endpoints->register();
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
         $this->router = $router->route($route);
322 322
         $endpoint = $this->endpoints->isEndpoint($router->getApi(), $router->getPath());
323 323
 
324
-        if(isset($endpoint->model['scope'])) {
324
+        if (isset($endpoint->model['scope'])) {
325 325
             $_REQUEST['scope'] = $endpoint->model['scope'];
326 326
             $this->header->setData($_REQUEST);
327 327
         }
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
         /**
407 407
          * Check if theres a request payload sent
408 408
          */
409
-        if(isset($_REQUEST['payload'])) {
409
+        if (isset($_REQUEST['payload'])) {
410 410
             $router->setRequestBody($_REQUEST['payload']);
411 411
         }
412 412
         $router->setPostBody($this->header->getBody());
@@ -417,11 +417,11 @@  discard block
 block discarded – undo
417 417
         /**
418 418
          * Check the access scope
419 419
          */
420
-        if( !isset($this->router->endpoint->model['scope']) ) {
420
+        if (!isset($this->router->endpoint->model['scope'])) {
421 421
             $this->router->endpoint->model['scope'] = 'private';
422 422
         }
423 423
 
424
-        if( isset($this->header->getMethod()->data['scope']) && 
424
+        if (isset($this->header->getMethod()->data['scope']) && 
425 425
             ($this->header->getMethod()->data['scope'] == 'anonymous')
426 426
         ) {
427 427
             $this->router->endpoint->model['scope'] = 'anonymous';
Please login to merge, or discard this patch.
src/core/auth/jwtDecoder.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
         $payloadObject = $cipher->jsonDecode($cipher->decode($jwtPayload));
52 52
 
53 53
         // @codeCoverageIgnoreStart
54
-        if( $this->key == 'payloadOnly' ) {
54
+        if ($this->key == 'payloadOnly') {
55 55
             return $payloadObject;
56 56
         }
57 57
         // @codeCoverageIgnoreEnd
Please login to merge, or discard this patch.
src/core/auth/jwt.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
      * @var array
53 53
      */
54 54
     protected static $ALGORITHMS = [
55
-        'HS256','sha256',
56
-        'HS384','sha384',
57
-        'HS512','sha512',
55
+        'HS256', 'sha256',
56
+        'HS384', 'sha384',
57
+        'HS512', 'sha512',
58 58
     ];
59 59
 
60 60
     /**
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
      * [getOptions]
253 253
      * @return array
254 254
      */
255
-    public function getOptions():?array
255
+    public function getOptions(): ?array
256 256
     {
257 257
         return self::$options;
258 258
     }
Please login to merge, or discard this patch.
src/core/route/router.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public function setPostBody($payload)
104 104
     {
105
-        if( !empty($this->payloadBody) ) {
105
+        if (!empty($this->payloadBody)) {
106 106
             $payload = array_merge($this->payloadBody, ['post' => $payload]);
107 107
         }
108 108
 
109
-        if( !empty($this->requestBody) ) {
109
+        if (!empty($this->requestBody)) {
110 110
             $payload = array_merge($this->requestBody, ['post' => $payload]);
111 111
         }
112 112
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      */
145 145
     public function getRequestBody()
146 146
     {
147
-        if( isset($this->requestBody['payload']) ) {
147
+        if (isset($this->requestBody['payload'])) {
148 148
             return $this->requestBody['payload'];
149 149
         }
150 150
         return $this->requestBody;
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
             ),
197 197
         );
198 198
 
199
-        $this->setRoutes((object)$routesArray);
199
+        $this->setRoutes((object) $routesArray);
200 200
 
201 201
         return $this->getRoutes();
202 202
     }
Please login to merge, or discard this patch.
src/core/endpoints/map.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -76,14 +76,14 @@  discard block
 block discarded – undo
76 76
         /**
77 77
          * Check if a custom directory was set in the Responsible API options
78 78
          */
79
-        if( (isset($options['classRoute']) && !empty($options['classRoute'])) && 
79
+        if ((isset($options['classRoute']) && !empty($options['classRoute'])) && 
80 80
             (isset($options['classRoute']['directory']) && isset($options['classRoute']['namespace']))
81 81
         ) {
82 82
             $customService = $this->options['classRoute'];
83 83
             $directory = $customService['directory'];
84 84
             $middleware = $customService['namespace'];
85 85
 
86
-        }else {
86
+        } else {
87 87
             $middleware = 'responsible';
88 88
 
89 89
             $endpoint = str_replace(
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
                 if (class_exists($child) && method_exists($child, 'register')) {
142 142
                     self::$middleWareClass = new $child;
143 143
                     $this->registry[$point] = self::$middleWareClass->register();
144
-                }else{
144
+                } else {
145 145
                     (new exception\errorException)
146 146
                         ->setOptions($this->getOptions())
147 147
                         ->message("Class Error:: class {$child} needs to exist. See documentation on setting up a service.")
@@ -232,16 +232,16 @@  discard block
 block discarded – undo
232 232
                  * @var array
233 233
                  */
234 234
                 if (array_search($endpoint, $this->registry[$api]) !== false) {
235
-                    if( method_exists($this->NAMESPACE_ENDPOINTS[$api], 'scope') ) {
235
+                    if (method_exists($this->NAMESPACE_ENDPOINTS[$api], 'scope')) {
236 236
                         $classScope = (new $this->NAMESPACE_ENDPOINTS[$api])->scope();
237 237
                         $position = array_search($endpoint, $this->registry[$api]);
238 238
                         
239
-                        if( is_array($classScope) && isset($classScope[$position]) ) {
239
+                        if (is_array($classScope) && isset($classScope[$position])) {
240 240
                             $endpointSettings['model']['scope'] = $classScope[$position];
241 241
 
242
-                        }else{
242
+                        } else {
243 243
 
244
-                            if( !is_array($classScope) ) {
244
+                            if (!is_array($classScope)) {
245 245
                                 $endpointSettings['model']['scope'] = $classScope;
246 246
                             }
247 247
                         }
@@ -292,16 +292,16 @@  discard block
 block discarded – undo
292 292
 
293 293
                         $scope = 'private';
294 294
 
295
-                        if( method_exists($this->NAMESPACE_ENDPOINTS[$api], 'scope') ) {
295
+                        if (method_exists($this->NAMESPACE_ENDPOINTS[$api], 'scope')) {
296 296
                             $classScope = (new $this->NAMESPACE_ENDPOINTS[$api])->scope();
297 297
                             $position = array_search($path, $this->registry[$api]);
298 298
                             
299
-                            if( is_array($classScope) && isset($classScope[$position]) ) {
299
+                            if (is_array($classScope) && isset($classScope[$position])) {
300 300
                                 $scope = $classScope[$position];
301 301
 
302
-                            }else{
302
+                            } else {
303 303
 
304
-                                if( !is_array($classScope) ) {
304
+                                if (!is_array($classScope)) {
305 305
                                     $scope = $classScope;
306 306
                                 }
307 307
                             }
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             $directory = $customService['directory'];
84 84
             $middleware = $customService['namespace'];
85 85
 
86
-        }else {
86
+        } else {
87 87
             $middleware = 'responsible';
88 88
 
89 89
             $endpoint = str_replace(
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
                 if (class_exists($child) && method_exists($child, 'register')) {
142 142
                     self::$middleWareClass = new $child;
143 143
                     $this->registry[$point] = self::$middleWareClass->register();
144
-                }else{
144
+                } else{
145 145
                     (new exception\errorException)
146 146
                         ->setOptions($this->getOptions())
147 147
                         ->message("Class Error:: class {$child} needs to exist. See documentation on setting up a service.")
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
                         if( is_array($classScope) && isset($classScope[$position]) ) {
240 240
                             $endpointSettings['model']['scope'] = $classScope[$position];
241 241
 
242
-                        }else{
242
+                        } else{
243 243
 
244 244
                             if( !is_array($classScope) ) {
245 245
                                 $endpointSettings['model']['scope'] = $classScope;
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
                             if( is_array($classScope) && isset($classScope[$position]) ) {
300 300
                                 $scope = $classScope[$position];
301 301
 
302
-                            }else{
302
+                            } else{
303 303
 
304 304
                                 if( !is_array($classScope) ) {
305 305
                                     $scope = $classScope;
Please login to merge, or discard this patch.
src/responsible.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
         // Authenticate the API connections
145 145
         try {
146 146
             $this->server->authenticate();
147
-        }catch (responsibleException | \Exception $e) {
147
+        } catch (responsibleException | \Exception $e) {
148 148
             self::$response = $e->getMessage();
149 149
             return;
150 150
         }
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
                 $this->getRateLimit(),
156 156
                 $this->getRateWindow()
157 157
             );
158
-        }catch (responsibleException | \Exception $e) {
158
+        } catch (responsibleException | \Exception $e) {
159 159
             self::$response = $e->getMessage();
160 160
             return;
161 161
         }
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         // Build the APIs internal router
164 164
         try {
165 165
             $this->server->route($route);
166
-        }catch (responsibleException | \Exception $e) {
166
+        } catch (responsibleException | \Exception $e) {
167 167
             self::$response = $e->getMessage();
168 168
             return;
169 169
         }
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
         $getJWT = (isset($options['getJWT']) && is_bool($options['getJWT']))
373 373
         ? $options['getJWT'] : true;
374 374
 
375
-        $getSecretAppend = (isset($options['secret']) && ($options['secret'] == 'append') )
375
+        $getSecretAppend = (isset($options['secret']) && ($options['secret'] == 'append'))
376 376
         ? $options['secret'] : false;
377 377
 
378 378
         return (new user\user)
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
         // Authenticate the API connections
145 145
         try {
146 146
             $this->server->authenticate();
147
-        }catch (responsibleException | \Exception $e) {
147
+        } catch (responsibleException | \Exception $e) {
148 148
             self::$response = $e->getMessage();
149 149
             return;
150 150
         }
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
                 $this->getRateLimit(),
156 156
                 $this->getRateWindow()
157 157
             );
158
-        }catch (responsibleException | \Exception $e) {
158
+        } catch (responsibleException | \Exception $e) {
159 159
             self::$response = $e->getMessage();
160 160
             return;
161 161
         }
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         // Build the APIs internal router
164 164
         try {
165 165
             $this->server->route($route);
166
-        }catch (responsibleException | \Exception $e) {
166
+        } catch (responsibleException | \Exception $e) {
167 167
             self::$response = $e->getMessage();
168 168
             return;
169 169
         }
Please login to merge, or discard this patch.