@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * [PACKAGE description] |
| 84 | 84 | * @var string |
| 85 | 85 | */ |
| 86 | - const PACKAGE = "francis94c/ci-rest"; |
|
| 86 | + const PACKAGE = "francis94c/ci-rest"; |
|
| 87 | 87 | /** |
| 88 | 88 | * [RATE_LIMIT description] |
| 89 | 89 | * @var string |
@@ -97,8 +97,8 @@ discard block |
||
| 97 | 97 | * @param array|null $params Initialization parameters from the Slint system. |
| 98 | 98 | * There's no use for this arg yet. |
| 99 | 99 | */ |
| 100 | - function __construct($params=null) { |
|
| 101 | - $this->ci =& get_instance(); |
|
| 100 | + function __construct($params = null) { |
|
| 101 | + $this->ci = & get_instance(); |
|
| 102 | 102 | // Load Config If Exists. |
| 103 | 103 | $this->ci->config->load('rest', true, true); |
| 104 | 104 | // Load Database. |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | $this->ci->load->helper('url'); |
| 108 | 108 | // Load Model. |
| 109 | 109 | $this->ci->load->splint(self::PACKAGE, '*RESTModel', 'rest_model'); |
| 110 | - $this->rest_model =& $this->ci->rest_model; |
|
| 110 | + $this->rest_model = & $this->ci->rest_model; |
|
| 111 | 111 | $config = [ |
| 112 | 112 | 'users_table' => $this->ci->config->item('rest')['basic_auth']['users_table'] ?? null, |
| 113 | 113 | 'users_id_column' => $this->ci->config->item('rest')['basic_auth']['id_column'] ?? null, |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | /** |
| 197 | 197 | * [bearer_auth description] |
| 198 | 198 | */ |
| 199 | - private function bearer_auth($auth=RESTAuth::BEARER):void { |
|
| 199 | + private function bearer_auth($auth = RESTAuth::BEARER):void { |
|
| 200 | 200 | $authorization = $this->get_authorization_header(); |
| 201 | 201 | if ($authorization == null || substr_count($authorization, " ") != 1) { |
| 202 | 202 | $this->handle_response(RESTResponse::BAD_REQUEST, $auth); // Exits. |
@@ -229,11 +229,11 @@ discard block |
||
| 229 | 229 | * [api_key_auth description] |
| 230 | 230 | */ |
| 231 | 231 | private function api_key_auth():void { |
| 232 | - if (!isset($_SERVER['HTTP_' . str_replace("-", "_", $this->apiKeyHeader)])) { |
|
| 232 | + if (!isset($_SERVER['HTTP_'.str_replace("-", "_", $this->apiKeyHeader)])) { |
|
| 233 | 233 | $this->handle_response(RESTResponse::BAD_REQUEST, RESTAuth::API_KEY); // Exits. |
| 234 | 234 | } |
| 235 | 235 | $apiKey = $this->rest_model->getAPIKeyData( |
| 236 | - $_SERVER['HTTP_' . str_replace("-", "_", $this->apiKeyHeader)] |
|
| 236 | + $_SERVER['HTTP_'.str_replace("-", "_", $this->apiKeyHeader)] |
|
| 237 | 237 | ); |
| 238 | 238 | if ($apiKey == null) { |
| 239 | 239 | $this->handle_response(RESTResponse::UN_AUTHORIZED, RESTAuth::API_KEY); // Exits. |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | } |
| 250 | 250 | // Should we acyually Limit? |
| 251 | 251 | if ($this->per_hour > 0) { |
| 252 | - $client = hash('md5', $this->ci->input->ip_address() . "%" . $apiKey[$this->api_key_column]); |
|
| 252 | + $client = hash('md5', $this->ci->input->ip_address()."%".$apiKey[$this->api_key_column]); |
|
| 253 | 253 | $limitData = $this->rest_model->getLimitData($client, '_api_keyed_user'); |
| 254 | 254 | if ($limitData == null) { |
| 255 | 255 | $limitData = []; |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | * [get_authorization_header description] |
| 333 | 333 | * @return [type] [description] |
| 334 | 334 | */ |
| 335 | - private function get_authorization_header():?string { |
|
| 335 | + private function get_authorization_header(): ?string { |
|
| 336 | 336 | if (isset($_SERVER['Authorization'])) { |
| 337 | 337 | return trim($_SERVER["Authorization"]); |
| 338 | 338 | } else if (isset($_SERVER['HTTP_AUTHORIZATION'])) { //Nginx or fast CGI |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | * [handle_response description] |
| 354 | 354 | * @param int $code [description] |
| 355 | 355 | */ |
| 356 | - private function handle_response(int $code, $auth=null):void { |
|
| 356 | + private function handle_response(int $code, $auth = null):void { |
|
| 357 | 357 | http_response_code($code); |
| 358 | 358 | header("Content-Type: application/json"); |
| 359 | 359 | if (isset($this->ci->config->item('rest')['response_callbacks'][$code])) { |