@@ -137,16 +137,16 @@ discard block |
||
| 137 | 137 | * @param array|null $params Initialization parameters from the Slint system. |
| 138 | 138 | * There's no use for this arg yet. |
| 139 | 139 | */ |
| 140 | - function __construct(?array $params=null) |
|
| 140 | + function __construct(?array $params = null) |
|
| 141 | 141 | { |
| 142 | - $this->ci =& get_instance(); |
|
| 142 | + $this->ci = & get_instance(); |
|
| 143 | 143 | |
| 144 | 144 | if ($this->ci->input->is_cli_request()) return; |
| 145 | 145 | |
| 146 | 146 | // Load Config If Exists. |
| 147 | 147 | //$this->ci->config->load('rest', true, true); |
| 148 | - if (is_file(APPPATH . 'config/rest.php')) { |
|
| 149 | - include APPPATH . 'config/rest.php'; |
|
| 148 | + if (is_file(APPPATH.'config/rest.php')) { |
|
| 149 | + include APPPATH.'config/rest.php'; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | $this->config = $config; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | // Load Model. |
| 164 | 164 | $this->ci->load->splint(self::PACKAGE, '*RESTModel', 'rest_model'); |
| 165 | - $this->rest_model =& $this->ci->rest_model; |
|
| 165 | + $this->rest_model = & $this->ci->rest_model; |
|
| 166 | 166 | |
| 167 | 167 | $this->rest_model->init([ |
| 168 | 168 | 'users_table' => $config['basic_auth']['users_table'] ?? null, |
@@ -262,14 +262,14 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | private function auth_proceed(bool $success, int $flags):bool |
| 264 | 264 | { |
| 265 | - if ($flags & self::AUTH_GRAVITY) return $success; |
|
| 265 | + if ($flags&self::AUTH_GRAVITY) return $success; |
|
| 266 | 266 | if ($success) { |
| 267 | - if ($flags & self::AUTH_FINAL) { |
|
| 267 | + if ($flags&self::AUTH_FINAL) { |
|
| 268 | 268 | $this->authPreempted = true; |
| 269 | 269 | return true; |
| 270 | 270 | } |
| 271 | 271 | } else { |
| 272 | - return $flags & self::AUTH_PASSIVE ? true : false; |
|
| 272 | + return $flags&self::AUTH_PASSIVE ? true : false; |
|
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | 275 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | /** |
| 330 | 330 | * [api_key_auth description] |
| 331 | 331 | */ |
| 332 | - private function api_key_auth(int $flags=self::AUTH_GRAVITY):void |
|
| 332 | + private function api_key_auth(int $flags = self::AUTH_GRAVITY):void |
|
| 333 | 333 | { |
| 334 | 334 | if (uri_string() == '') return; |
| 335 | 335 | $shouldProceed = $this->auth_proceed(false, $flags); |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | } |
| 377 | 377 | // Should we acyually Limit? |
| 378 | 378 | if ($this->per_hour > 0) { |
| 379 | - $client = hash('md5', $this->ci->input->ip_address() . "%" . $apiKey); |
|
| 379 | + $client = hash('md5', $this->ci->input->ip_address()."%".$apiKey); |
|
| 380 | 380 | $limitData = $this->rest_model->getLimitData($client, '_api_keyed_user'); |
| 381 | 381 | if ($limitData == null) { |
| 382 | 382 | $limitData = []; |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | * [get_authorization_header description] |
| 461 | 461 | * @return [type] [description] |
| 462 | 462 | */ |
| 463 | - private function get_authorization_header():?string |
|
| 463 | + private function get_authorization_header(): ?string |
|
| 464 | 464 | { |
| 465 | 465 | if (isset($_SERVER['Authorization'])) { |
| 466 | 466 | return trim($_SERVER["Authorization"]); |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | * [handle_response description] |
| 484 | 484 | * @param int $code [description] |
| 485 | 485 | */ |
| 486 | - private function handle_response(int $code, $auth=null, ?string $errorReason=null):void |
|
| 486 | + private function handle_response(int $code, $auth = null, ?string $errorReason = null):void |
|
| 487 | 487 | { |
| 488 | 488 | http_response_code($code); |
| 489 | 489 | header("Content-Type: application/json"); |