Passed
Push — master ( 890c1d...8fd1e9 )
by Vince
01:21
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 1 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 1 patch
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.
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/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.
src/core/user/user.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
      */
131 131
     private function updateAccount($properties)
132 132
     {
133
-        if( is_array($properties) ) {
133
+        if (is_array($properties)) {
134 134
             $properties = (object) $properties; //json_decode(json_encode($properties));
135 135
         }
136 136
 
137
-        if( !isset($properties->update) || 
137
+        if (!isset($properties->update) || 
138 138
             !isset($properties->where) || 
139 139
             (isset($properties->update) && !is_array($properties->update)) ||
140 140
             (isset($properties->where) && !is_array($properties->where))
@@ -161,16 +161,16 @@  discard block
 block discarded – undo
161 161
          * @var [type]
162 162
          */
163 163
         foreach ($properties->update as $u => $update) {
164
-            if( !in_array($u, $allowedFileds) ) {
164
+            if (!in_array($u, $allowedFileds)) {
165 165
                 unset($properties->update[$u]);
166
-            }else{
166
+            } else {
167 167
                 $set .= $u . ' = :' . $u . ',';
168 168
                 $binds[$u] = $update;
169 169
             }
170 170
         }
171 171
 
172 172
         $set = rtrim($set, ',');
173
-        $where =  key($properties->where) . ' = ' . $properties->where[key($properties->where)];
173
+        $where = key($properties->where) . ' = ' . $properties->where[key($properties->where)];
174 174
 
175 175
         return $this->DB()->
176 176
             query(
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
         $options = $this->getOptions();
215 215
         $skipValidatation = false;
216 216
 
217
-        if( isset($options['validate']) && $options['validate'] == false ) {
217
+        if (isset($options['validate']) && $options['validate'] == false) {
218 218
             $skipValidatation = true;
219 219
         }
220 220
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
                 break;
231 231
 
232 232
             case 'mail':
233
-                if( !filter_var($property, FILTER_VALIDATE_EMAIL) && !$skipValidatation) {
233
+                if (!filter_var($property, FILTER_VALIDATE_EMAIL) && !$skipValidatation) {
234 234
                     return;
235 235
                 }
236 236
                 $this->mail = $property;
Please login to merge, or discard this patch.