@@ -52,7 +52,7 @@ |
||
| 52 | 52 | ->decode() |
| 53 | 53 | ; |
| 54 | 54 | |
| 55 | - $this->assertEquals(true, (is_array($decoded)&&!empty($decoded)) ); |
|
| 55 | + $this->assertEquals(true, (is_array($decoded) && !empty($decoded))); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -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 | } |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | */ |
| 296 | 296 | public function getAccount() |
| 297 | 297 | { |
| 298 | - if (is_null($this->account)||empty($this->account)) { |
|
| 298 | + if (is_null($this->account) || empty($this->account)) { |
|
| 299 | 299 | (new exception\errorException) |
| 300 | 300 | ->setOptions($this->getOptions()) |
| 301 | 301 | ->error('UNAUTHORIZED'); |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | |
| 401 | 401 | if (is_numeric($timeframe)) { |
| 402 | 402 | if ($timeframe < 0) { |
| 403 | - $timeframe = ($timeframe*-1); |
|
| 403 | + $timeframe = ($timeframe * -1); |
|
| 404 | 404 | } |
| 405 | 405 | self::$timeframe['CUSTOM'] = $timeframe; |
| 406 | 406 | $this->window = intval(self::$timeframe['CUSTOM']); |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * [getOptions Get the stored Responsible API options] |
| 163 | 163 | * @return array|null |
| 164 | 164 | */ |
| 165 | - public function getOptions():?array |
|
| 165 | + public function getOptions(): ?array |
|
| 166 | 166 | { |
| 167 | 167 | return $this->options; |
| 168 | 168 | } |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | return; |
| 217 | 217 | } |
| 218 | 218 | if (is_null($key) || $key == '') { |
| 219 | - if( !is_null($response) ) { |
|
| 219 | + if (!is_null($response)) { |
|
| 220 | 220 | $this->RESPONSE['response'] = $response; |
| 221 | 221 | } |
| 222 | 222 | return; |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | public function authenticate() |
| 259 | 259 | { |
| 260 | 260 | $options = $this->getOptions(); |
| 261 | - $route = (isset($options['route']) && !empty($options['route']) ) ? $options['route'] : ''; |
|
| 261 | + $route = (isset($options['route']) && !empty($options['route'])) ? $options['route'] : ''; |
|
| 262 | 262 | |
| 263 | 263 | $this->endpoints->baseApiRoot(dirname(__DIR__)); |
| 264 | 264 | $this->endpoints->register(); |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | $this->router = $router->route($route); |
| 270 | 270 | $endpoint = $this->endpoints->isEndpoint($router->getApi(), $router->getPath()); |
| 271 | 271 | |
| 272 | - if(isset($endpoint->model['scope'])) { |
|
| 272 | + if (isset($endpoint->model['scope'])) { |
|
| 273 | 273 | $_REQUEST['scope'] = $endpoint->model['scope']; |
| 274 | 274 | $this->header->setData($_REQUEST); |
| 275 | 275 | } |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | /** |
| 348 | 348 | * Check if theres a payload sent |
| 349 | 349 | */ |
| 350 | - if(isset($_REQUEST['payload'])) { |
|
| 350 | + if (isset($_REQUEST['payload'])) { |
|
| 351 | 351 | $router->setRequestBody($_REQUEST['payload']); |
| 352 | 352 | } |
| 353 | 353 | // print_r($_REQUEST); |
@@ -359,11 +359,11 @@ discard block |
||
| 359 | 359 | /** |
| 360 | 360 | * Check the access scope |
| 361 | 361 | */ |
| 362 | - if( !isset($this->router->endpoint->model['scope']) ) { |
|
| 362 | + if (!isset($this->router->endpoint->model['scope'])) { |
|
| 363 | 363 | $this->router->endpoint->model['scope'] = 'private'; |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - if( isset($this->header->getMethod()->data['scope']) && |
|
| 366 | + if (isset($this->header->getMethod()->data['scope']) && |
|
| 367 | 367 | ($this->header->getMethod()->data['scope'] == 'anonymous') |
| 368 | 368 | ) { |
| 369 | 369 | $this->router->endpoint->model['scope'] = 'anonymous'; |