@@ -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; |
@@ -117,7 +117,7 @@ |
||
| 117 | 117 | ->decode() |
| 118 | 118 | ; |
| 119 | 119 | } |
| 120 | - }else{ |
|
| 120 | + } else{ |
|
| 121 | 121 | |
| 122 | 122 | $this->header->unauthorised(); |
| 123 | 123 | } |
@@ -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 | '-', |
@@ -88,7 +88,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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; |
@@ -76,14 +76,14 @@ discard block |
||
| 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( |
@@ -135,7 +135,7 @@ discard block |
||
| 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'); |
@@ -206,16 +206,16 @@ discard block |
||
| 206 | 206 | * @var array |
| 207 | 207 | */ |
| 208 | 208 | if (array_search($endpoint, $this->registry[$api]) !== false) { |
| 209 | - if( method_exists($this->NAMESPACE_ENDPOINTS[$api], 'scope') ) { |
|
| 209 | + if (method_exists($this->NAMESPACE_ENDPOINTS[$api], 'scope')) { |
|
| 210 | 210 | $classScope = (new $this->NAMESPACE_ENDPOINTS[$api])->scope(); |
| 211 | 211 | $position = array_search($endpoint, $this->registry[$api]); |
| 212 | 212 | |
| 213 | - if( is_array($classScope) && isset($classScope[$position]) ) { |
|
| 213 | + if (is_array($classScope) && isset($classScope[$position])) { |
|
| 214 | 214 | $endpointSettings['model']['scope'] = $classScope[$position]; |
| 215 | 215 | |
| 216 | - }else{ |
|
| 216 | + } else { |
|
| 217 | 217 | |
| 218 | - if( !is_array($classScope) ) { |
|
| 218 | + if (!is_array($classScope)) { |
|
| 219 | 219 | $endpointSettings['model']['scope'] = $classScope; |
| 220 | 220 | } |
| 221 | 221 | } |
@@ -266,16 +266,16 @@ discard block |
||
| 266 | 266 | |
| 267 | 267 | $scope = 'private'; |
| 268 | 268 | |
| 269 | - if( method_exists($this->NAMESPACE_ENDPOINTS[$api], 'scope') ) { |
|
| 269 | + if (method_exists($this->NAMESPACE_ENDPOINTS[$api], 'scope')) { |
|
| 270 | 270 | $classScope = (new $this->NAMESPACE_ENDPOINTS[$api])->scope(); |
| 271 | 271 | $position = array_search($path, $this->registry[$api]); |
| 272 | 272 | |
| 273 | - if( is_array($classScope) && isset($classScope[$position]) ) { |
|
| 273 | + if (is_array($classScope) && isset($classScope[$position])) { |
|
| 274 | 274 | $scope = $classScope[$position]; |
| 275 | 275 | |
| 276 | - }else{ |
|
| 276 | + } else { |
|
| 277 | 277 | |
| 278 | - if( !is_array($classScope) ) { |
|
| 278 | + if (!is_array($classScope)) { |
|
| 279 | 279 | $scope = $classScope; |
| 280 | 280 | } |
| 281 | 281 | } |
@@ -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; |
@@ -163,7 +163,7 @@ |
||
| 163 | 163 | foreach ($properties->update as $u => $update) { |
| 164 | 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 | } |
@@ -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; |