@@ -359,7 +359,7 @@ |
||
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) |
@@ -165,7 +165,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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'; |
@@ -65,7 +65,7 @@ |
||
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 |
@@ -50,7 +50,7 @@ |
||
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 |
@@ -63,7 +63,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -35,7 +35,7 @@ |
||
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 | '-', |
@@ -130,11 +130,11 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | 'post' => $payload |
101 | 101 | ]; |
102 | 102 | |
103 | - if( isset($this->requestBody['payload']) ) { |
|
103 | + if (isset($this->requestBody['payload'])) { |
|
104 | 104 | array_merge($this->requestBody['payload'], $payloadPost); |
105 | 105 | return; |
106 | 106 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function getRequestBody() |
127 | 127 | { |
128 | - if( isset($this->requestBody['payload']) ) { |
|
128 | + if (isset($this->requestBody['payload'])) { |
|
129 | 129 | return $this->requestBody['payload']; |
130 | 130 | } |
131 | 131 | return $this->requestBody; |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | foreach ($headers_list as $index => $headValue) { |
190 | 190 | @list($key, $value) = explode(": ", $headValue); |
191 | 191 | |
192 | - if (!is_null($key) && !is_null($value) ) { |
|
192 | + if (!is_null($key) && !is_null($value)) { |
|
193 | 193 | $headers_list[$key] = $value; |
194 | 194 | unset($headers_list[$index]); |
195 | 195 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | $apacheRequestHeaders = apache_request_headers(); |
202 | 202 | } |
203 | 203 | |
204 | - if( is_null($apacheRequestHeaders) || empty($apacheRequestHeaders) ) { |
|
204 | + if (is_null($apacheRequestHeaders) || empty($apacheRequestHeaders)) { |
|
205 | 205 | return []; |
206 | 206 | } |
207 | 207 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | '*', |
260 | 260 | )); |
261 | 261 | |
262 | - if( !array_key_exists('Access-Control-Allow-Methods', $this->getHeaders()) ) { |
|
262 | + if (!array_key_exists('Access-Control-Allow-Methods', $this->getHeaders())) { |
|
263 | 263 | $this->setHeader('Access-Control-Allow-Methods', array( |
264 | 264 | 'GET,POST,OPTIONS', |
265 | 265 | )); |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | ) |
459 | 459 | ); |
460 | 460 | |
461 | - if( empty($account) ) { |
|
461 | + if (empty($account)) { |
|
462 | 462 | $this->unauthorised(); |
463 | 463 | } |
464 | 464 |