@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * [BasicAuth description] |
| 7 | 7 | * @var string |
| 8 | 8 | */ |
| 9 | - const BASIC = "Basic"; |
|
| 9 | + const BASIC = "Basic"; |
|
| 10 | 10 | /** |
| 11 | 11 | * [API_KEY description] |
| 12 | 12 | * @var string |
@@ -16,17 +16,17 @@ discard block |
||
| 16 | 16 | * [BEARER description] |
| 17 | 17 | * @var string |
| 18 | 18 | */ |
| 19 | - const BEARER = "Bearer"; |
|
| 19 | + const BEARER = "Bearer"; |
|
| 20 | 20 | /** |
| 21 | 21 | * [OAUTH2 description] |
| 22 | 22 | * @var string |
| 23 | 23 | */ |
| 24 | - const OAUTH2 = "OAUTH2"; |
|
| 24 | + const OAUTH2 = "OAUTH2"; |
|
| 25 | 25 | /** |
| 26 | 26 | * [IP description] |
| 27 | 27 | * @var string |
| 28 | 28 | */ |
| 29 | - const IP = "IP"; |
|
| 29 | + const IP = "IP"; |
|
| 30 | 30 | /** |
| 31 | 31 | * [CUSTOM description] |
| 32 | 32 | * @param string $header [description] |
@@ -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,15 +97,15 @@ 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. |
| 105 | 105 | $this->ci->load->database(); |
| 106 | 106 | // Load Model. |
| 107 | 107 | $this->ci->load->splint(self::PACKAGE, '*RESTModel', 'rest_model'); |
| 108 | - $this->rest_model =& $this->ci->rest_model; |
|
| 108 | + $this->rest_model = & $this->ci->rest_model; |
|
| 109 | 109 | $config = [ |
| 110 | 110 | 'users_table' => $this->ci->config->item('rest')['basic_auth']['users_table'] ?? null, |
| 111 | 111 | 'users_id_column' => $this->ci->config->item('rest')['basic_auth']['id_column'] ?? null, |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | /** |
| 195 | 195 | * [bearer_auth description] |
| 196 | 196 | */ |
| 197 | - private function bearer_auth($auth=RESTAuth::BEARER):void { |
|
| 197 | + private function bearer_auth($auth = RESTAuth::BEARER):void { |
|
| 198 | 198 | $authorization = $this->get_authorization_header(); |
| 199 | 199 | if ($authorization == null || substr_count($authorization, " ") != 1) { |
| 200 | 200 | $this->handle_response(RESTResponse::BAD_REQUEST, $auth); // Exits. |
@@ -227,11 +227,11 @@ discard block |
||
| 227 | 227 | * [api_key_auth description] |
| 228 | 228 | */ |
| 229 | 229 | private function api_key_auth():void { |
| 230 | - if (!isset($_SERVER['HTTP_' . str_replace("-", "_", $this->apiKeyHeader)])) { |
|
| 230 | + if (!isset($_SERVER['HTTP_'.str_replace("-", "_", $this->apiKeyHeader)])) { |
|
| 231 | 231 | $this->handle_response(RESTResponse::BAD_REQUEST, RESTAuth::API_KEY); // Exits. |
| 232 | 232 | } |
| 233 | 233 | $apiKey = $this->rest_model->getAPIKeyData( |
| 234 | - $_SERVER['HTTP_' . str_replace("-", "_", $this->apiKeyHeader)] |
|
| 234 | + $_SERVER['HTTP_'.str_replace("-", "_", $this->apiKeyHeader)] |
|
| 235 | 235 | ); |
| 236 | 236 | if ($apiKey == null) { |
| 237 | 237 | $this->handle_response(RESTResponse::UN_AUTHORIZED, RESTAuth::API_KEY); // Exits. |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | } |
| 248 | 248 | // Should we acyually Limit? |
| 249 | 249 | if ($this->per_hour > 0) { |
| 250 | - $client = hash('md5', $this->ci->input->ip_address() . "%" . $apiKey[$this->api_key_column]); |
|
| 250 | + $client = hash('md5', $this->ci->input->ip_address()."%".$apiKey[$this->api_key_column]); |
|
| 251 | 251 | $limitData = $this->rest_model->getLimitData($client, '_api_keyed_user'); |
| 252 | 252 | if ($limitData == null) { |
| 253 | 253 | $limitData = []; |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | * [get_authorization_header description] |
| 331 | 331 | * @return [type] [description] |
| 332 | 332 | */ |
| 333 | - private function get_authorization_header():?string { |
|
| 333 | + private function get_authorization_header(): ?string { |
|
| 334 | 334 | if (isset($_SERVER['Authorization'])) { |
| 335 | 335 | return trim($_SERVER["Authorization"]); |
| 336 | 336 | } else if (isset($_SERVER['HTTP_AUTHORIZATION'])) { //Nginx or fast CGI |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | * [handle_response description] |
| 352 | 352 | * @param int $code [description] |
| 353 | 353 | */ |
| 354 | - private function handle_response(int $code, $auth=null):void { |
|
| 354 | + private function handle_response(int $code, $auth = null):void { |
|
| 355 | 355 | http_response_code($code); |
| 356 | 356 | header("Content-Type: application/json"); |
| 357 | 357 | if (isset($this->ci->config->item('rest')['response_callbacks'][$code])) { |