Passed
Branch master (25787f)
by Vince
03:40 queued 02:10
created
src/responsible.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -359,7 +359,7 @@
 block discarded – undo
359 359
         $getJWT = (isset($options['getJWT']) && is_bool($options['getJWT']))
360 360
         ? $options['getJWT'] : true;
361 361
 
362
-        $getSecretAppend = (isset($options['secret']) && ($options['secret'] == 'append') )
362
+        $getSecretAppend = (isset($options['secret']) && ($options['secret'] == 'append'))
363 363
         ? $options['secret'] : false;
364 364
 
365 365
         return (new user\user)
Please login to merge, or discard this patch.
src/core/server.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
             return;
166 166
         }
167 167
         if (is_null($key) || $key == '') {
168
-            if( !is_null($response) ) {
168
+            if (!is_null($response)) {
169 169
                 $this->RESPONSE['response'] = $response;
170 170
             }
171 171
             return;
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     public function authenticate()
207 207
     {
208 208
         $options = $this->getOptions();
209
-        $route = (isset($options['route']) && !empty($options['route']) ) ? $options['route'] : '';
209
+        $route = (isset($options['route']) && !empty($options['route'])) ? $options['route'] : '';
210 210
 
211 211
         $this->endpoints->baseApiRoot(dirname(__DIR__));
212 212
         $this->endpoints->register();
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
         $this->router = $router->route($route);
218 218
         $endpoint = $this->endpoints->isEndpoint($router->getApi(), $router->getPath());
219 219
 
220
-        if(isset($endpoint->model['scope'])) {
220
+        if (isset($endpoint->model['scope'])) {
221 221
             $_REQUEST['scope'] = $endpoint->model['scope'];
222 222
             $this->header->setData($_REQUEST);
223 223
         }
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
         /**
297 297
          * Check if theres a payload sent
298 298
          */
299
-        if(isset($_REQUEST['payload'])) {
299
+        if (isset($_REQUEST['payload'])) {
300 300
             $router->setRequestBody($_REQUEST['payload']);
301 301
         }
302 302
         // print_r($_REQUEST);
@@ -308,11 +308,11 @@  discard block
 block discarded – undo
308 308
         /**
309 309
          * Check the access scope
310 310
          */
311
-        if( !isset($this->router->endpoint->model['scope']) ) {
311
+        if (!isset($this->router->endpoint->model['scope'])) {
312 312
             $this->router->endpoint->model['scope'] = 'private';
313 313
         }
314 314
 
315
-        if( isset($this->header->getMethod()->data['scope']) && 
315
+        if (isset($this->header->getMethod()->data['scope']) && 
316 316
             ($this->header->getMethod()->data['scope'] == 'anonymous')
317 317
         ) {
318 318
             $this->router->endpoint->model['scope'] = 'anonymous';
Please login to merge, or discard this patch.
src/core/throttle/limiter.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@
 block discarded – undo
97 97
         if( isset($this->account->scope) &&
98 98
             ($this->account->scope == 'anonymous' || $this->account->scope == 'public')
99 99
         ) {
100
-           $this->scope = $this->account->scope;
100
+            $this->scope = $this->account->scope;
101 101
         }
102 102
 
103 103
         return $this;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@
 block discarded – undo
94 94
             $this->setUnlimited();
95 95
         }
96 96
 
97
-        if( isset($this->account->scope) &&
97
+        if (isset($this->account->scope) &&
98 98
             ($this->account->scope == 'anonymous' || $this->account->scope == 'public')
99 99
         ) {
100 100
            $this->scope = $this->account->scope;
Please login to merge, or discard this patch.
src/core/auth/jwtValidate.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
      */
66 66
     public static function payload(array $payloadObject = [])
67 67
     {
68
-        if( isset($payloadObject['scope']) && $payloadObject['scope'] == 'anonymous' ) {
68
+        if (isset($payloadObject['scope']) && $payloadObject['scope'] == 'anonymous') {
69 69
             return true;
70 70
         }
71 71
 
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
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
          */
51 51
         $payloadObject = $cipher->jsonDecode($cipher->decode($jwtPayload));
52 52
 
53
-        if( $this->key == 'payloadOnly' ) {
53
+        if ($this->key == 'payloadOnly') {
54 54
             return $payloadObject;
55 55
         }
56 56
 
Please login to merge, or discard this patch.
src/core/auth/authorise.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         /**
64 64
          * Check if a custom scope is set
65 65
          */
66
-        if( isset($this->header->getMethod()->data['scope']) && 
66
+        if (isset($this->header->getMethod()->data['scope']) && 
67 67
             ($this->header->getMethod()->data['scope'] == 'anonymous')
68 68
         ) {
69 69
             $this->grantAccess = true;
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
                 ->decode()
102 102
             ;
103 103
 
104
-            if( isset($decoded['sub']) && !empty($decoded['sub']) ) {
104
+            if (isset($decoded['sub']) && !empty($decoded['sub'])) {
105 105
 
106 106
                 $this->user = (object) (new user\user)
107 107
                     ->setOptions($this->getOptions())
108 108
                     ->load($decoded['sub'], ['refreshToken' => true])
109 109
                 ;
110 110
 
111
-                if ( !empty($this->user) ) {
111
+                if (!empty($this->user)) {
112 112
                     $jwt = new auth\jwt;
113 113
                     $decoded = $jwt
114 114
                         ->setOptions($this->getOptions())
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
                         ->decode()
118 118
                     ;
119 119
                 }
120
-            }else{
120
+            } else {
121 121
 
122 122
                 $this->header->unauthorised();
123 123
             }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
          * [$user Check user account]
128 128
          * @var [object]
129 129
          */
130
-        if ( (isset($decoded['sub']) && !empty($decoded['sub'])) && !$this->user ) {
130
+        if ((isset($decoded['sub']) && !empty($decoded['sub'])) && !$this->user) {
131 131
             $this->user = (object) (new user\user)
132 132
                 ->setOptions($this->getOptions())
133 133
                 ->load($decoded['sub'], ['refreshToken' => true])
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      */
149 149
     public function user()
150 150
     {
151
-        if( $this->isGrantType() ) {
151
+        if ($this->isGrantType()) {
152 152
             return (object) [
153 153
                 'uid' => -1,
154 154
                 'account_id' => 0,
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
             return;
178 178
         }
179 179
 
180
-        if( isset($this->header->getMethod()->data['scope']) && 
180
+        if (isset($this->header->getMethod()->data['scope']) && 
181 181
             ($this->header->getMethod()->data['scope'] == 'anonymous')
182 182
         ) {
183 183
             return;
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@
 block discarded – undo
117 117
                         ->decode()
118 118
                     ;
119 119
                 }
120
-            }else{
120
+            } else{
121 121
 
122 122
                 $this->header->unauthorised();
123 123
             }
Please login to merge, or discard this patch.
src/core/keys/key.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
      */
36 36
     public function apiKeyGenerate($length = 32)
37 37
     {
38
-        $randInt = microtime().rand(1000, 9999);
38
+        $randInt = microtime() . rand(1000, 9999);
39 39
         $messageDigest = md5($randInt);
40 40
         return implode(
41 41
             '-',
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
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
         /**
82 82
          * Check if a custom directory was set in the Responsible API options
83 83
          */
84
-        if( (isset($this->options['classRoute']) && !empty($this->options['classRoute'])) && 
84
+        if ((isset($this->options['classRoute']) && !empty($this->options['classRoute'])) && 
85 85
             (isset($this->options['classRoute']['directory']) && isset($this->options['classRoute']['namespace']))
86 86
         ) {
87 87
             $customService = $this->options['classRoute'];
88 88
             $directory = $customService['directory'];
89 89
             $middleware = $customService['namespace'];
90 90
 
91
-        }else {
91
+        } else {
92 92
             $middleware = 'responsible';
93 93
 
94 94
             $endpoint = str_replace(
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
                 if (class_exists($child)) {
136 136
                     self::$middleWareClass = new $child;
137 137
                     $this->registry[$point] = self::$middleWareClass->register();
138
-                }else{
138
+                } else {
139 139
                     (new exception\errorException)
140 140
                         ->message("Class Error:: class {$child} needs to exist. See documentation on setting up a service.")
141 141
                         ->error('NOT_EXTENDED');
@@ -208,16 +208,16 @@  discard block
 block discarded – undo
208 208
                 if ($found = array_search($endpoint, $this->registry[$api]) !== false) {
209 209
                     
210 210
                     $scope = 'private';
211
-                    if( method_exists($this->NAMESPACE_ENDPOINTS[$api], 'scope') ) {
211
+                    if (method_exists($this->NAMESPACE_ENDPOINTS[$api], 'scope')) {
212 212
                         $classScope = (new $this->NAMESPACE_ENDPOINTS[$api])->scope();
213 213
                         $position = array_search($endpoint, $this->registry[$api]);
214 214
                         
215
-                        if( is_array($classScope) && isset($classScope[$position]) ) {
215
+                        if (is_array($classScope) && isset($classScope[$position])) {
216 216
                             $endpointSettings['model']['scope'] = $classScope[$position];
217 217
 
218
-                        }else{
218
+                        } else {
219 219
 
220
-                            if( !is_array($classScope) ) {
220
+                            if (!is_array($classScope)) {
221 221
                                 $endpointSettings['model']['scope'] = $classScope;
222 222
                             }
223 223
                         }
@@ -267,16 +267,16 @@  discard block
 block discarded – undo
267 267
                         }
268 268
 
269 269
                         $scope = 'private';
270
-                        if( method_exists($this->NAMESPACE_ENDPOINTS[$api], 'scope') ) {
270
+                        if (method_exists($this->NAMESPACE_ENDPOINTS[$api], 'scope')) {
271 271
                             $classScope = (new $this->NAMESPACE_ENDPOINTS[$api])->scope();
272 272
                             $position = array_search($path, $this->registry[$api]);
273 273
                             
274
-                            if( is_array($classScope) && isset($classScope[$position]) ) {
274
+                            if (is_array($classScope) && isset($classScope[$position])) {
275 275
                                 $scope = $classScope[$position];
276 276
 
277
-                            }else{
277
+                            } else {
278 278
 
279
-                                if( !is_array($classScope) ) {
279
+                                if (!is_array($classScope)) {
280 280
                                     $scope = $classScope;
281 281
                                 }
282 282
                             }
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
             $directory = $customService['directory'];
89 89
             $middleware = $customService['namespace'];
90 90
 
91
-        }else {
91
+        } else {
92 92
             $middleware = 'responsible';
93 93
 
94 94
             $endpoint = str_replace(
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
                 if (class_exists($child)) {
136 136
                     self::$middleWareClass = new $child;
137 137
                     $this->registry[$point] = self::$middleWareClass->register();
138
-                }else{
138
+                } else{
139 139
                     (new exception\errorException)
140 140
                         ->message("Class Error:: class {$child} needs to exist. See documentation on setting up a service.")
141 141
                         ->error('NOT_EXTENDED');
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
                         if( is_array($classScope) && isset($classScope[$position]) ) {
216 216
                             $endpointSettings['model']['scope'] = $classScope[$position];
217 217
 
218
-                        }else{
218
+                        } else{
219 219
 
220 220
                             if( !is_array($classScope) ) {
221 221
                                 $endpointSettings['model']['scope'] = $classScope;
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
                             if( is_array($classScope) && isset($classScope[$position]) ) {
275 275
                                 $scope = $classScope[$position];
276 276
 
277
-                            }else{
277
+                            } else{
278 278
 
279 279
                                 if( !is_array($classScope) ) {
280 280
                                     $scope = $classScope;
Please login to merge, or discard this patch.
src/core/user/userLoad.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
         $this->secret = $this->getDefaults()['config']['MASTER_KEY'];
87 87
 
88
-        if( isset($options['secret']) && $options['secret'] == 'append' ) {
88
+        if (isset($options['secret']) && $options['secret'] == 'append') {
89 89
             $this->secretAppend = true;
90 90
         }
91 91
     }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
                 \PDO::FETCH_OBJ
125 125
             );
126 126
 
127
-        if( $this->secretAppend ) {
127
+        if ($this->secretAppend) {
128 128
             $this->secret = $account->secret;
129 129
         }
130 130
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
                 $account->refresh_token = $this->refreshTokenGenerate($account);
138 138
                 $sentToken = (new headers\header)->hasBearerToken();
139 139
 
140
-                if( $sentToken ) {
140
+                if ($sentToken) {
141 141
                     /**
142 142
                      * [$jwt Decode the JWT]
143 143
                      * @var auth\jwt
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
                     ;
156 156
                     $absSeconds = ($decoded['exp'] - ($this->timeNow() - $leeway));
157 157
 
158
-                    if( $absSeconds > 0 ) {
158
+                    if ($absSeconds > 0) {
159 159
                         $account->JWT = $sentToken;
160 160
                     }
161 161
 
@@ -193,21 +193,21 @@  discard block
 block discarded – undo
193 193
     public function refreshTokenGenerate($account)
194 194
     {
195 195
         $offset = 86400;
196
-        $time = ($this->timeNow()+$offset);
196
+        $time = ($this->timeNow() + $offset);
197 197
 
198
-        if( isset($account->refresh_token) && !empty($account->refresh_token) ) {
198
+        if (isset($account->refresh_token) && !empty($account->refresh_token)) {
199 199
             $raToken = explode('.', $account->refresh_token);
200
-            if( is_array($raToken) ) {
200
+            if (is_array($raToken)) {
201 201
                 $raToken = array_values(array_filter($raToken));
202
-                $time = ($raToken[0] <= ($this->timeNow()-$offset) ) ? ($this->timeNow()+$offset) : $raToken[0];
202
+                $time = ($raToken[0] <= ($this->timeNow() - $offset)) ? ($this->timeNow() + $offset) : $raToken[0];
203 203
             }
204 204
         }
205 205
 
206 206
         $cipher = new encoder\cipher;
207
-        $refreshHash = $account->account_id.':'.$account->secret;
207
+        $refreshHash = $account->account_id . ':' . $account->secret;
208 208
         $refreshHash = $cipher->encode($cipher->hash('sha256', $refreshHash, $account->secret));
209 209
 
210
-        $refreshHash = $time.'.'.$refreshHash;
210
+        $refreshHash = $time . '.' . $refreshHash;
211 211
         $account->refreshToken = $refreshHash;
212 212
 
213 213
         $updateProp = [
@@ -342,26 +342,26 @@  discard block
 block discarded – undo
342 342
                 $payload['iat'] = $iat;
343 343
             }
344 344
             if (false !== ($nbf = $this->checkVal($jwtOptions, 'notBeFor'))) {
345
-                if( strtolower($nbf) == 'issuedat' && isset($payload['iat']) ) {
345
+                if (strtolower($nbf) == 'issuedat' && isset($payload['iat'])) {
346 346
                     $nbf = $payload['iat'] + 10;
347 347
                 }
348 348
                 $payload['nbf'] = $nbf;
349 349
             }
350 350
         }
351 351
 
352
-        if( $refresh && $exp ) {
352
+        if ($refresh && $exp) {
353 353
             $refreshPayload = $payload;
354 354
 
355 355
             $offset = $exp - $this->timeNow();
356 356
             $leeway = ($this->checkVal($this->options['jwt'], 'leeway')) ?: $this->jwt->getLeeway();
357 357
 
358
-            $refreshPayload['exp'] = $exp+$offset+$leeway;
358
+            $refreshPayload['exp'] = $exp + $offset + $leeway;
359 359
 
360 360
             $refreshJWT = $this->refreshJWT([
361 361
                 'payload' => $refreshPayload
362 362
             ]);
363 363
 
364
-            if( isset($refreshJWT['refresh']) ) {
364
+            if (isset($refreshJWT['refresh'])) {
365 365
                 return $refreshJWT['refresh'];
366 366
             }
367 367
         }
Please login to merge, or discard this patch.