Passed
Push — master ( abf407...1dadcc )
by Francis
01:18
created
libraries/REST.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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.
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     $this->ci->load->splint(self::PACKAGE, '%rest');
110 110
     // Load Model.
111 111
     $this->ci->load->splint(self::PACKAGE, '*RESTModel', 'rest_model');
112
-    $this->rest_model =& $this->ci->rest_model;
112
+    $this->rest_model = & $this->ci->rest_model;
113 113
     $config = [
114 114
       'users_table'           => $this->ci->config->item('rest')['basic_auth']['users_table'] ?? null,
115 115
       'users_id_column'       => $this->ci->config->item('rest')['basic_auth']['id_column'] ?? null,
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
   /**
199 199
    * [bearer_auth description]
200 200
    */
201
-  private function bearer_auth($auth=RESTAuth::BEARER):void {
201
+  private function bearer_auth($auth = RESTAuth::BEARER):void {
202 202
     $authorization = $this->get_authorization_header();
203 203
     if ($authorization == null || substr_count($authorization, " ") != 1) {
204 204
       $this->handle_response(RESTResponse::BAD_REQUEST, $auth); // Exits.
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
    * [api_key_auth description]
232 232
    */
233 233
   private function api_key_auth():void {
234
-    if (!isset($_SERVER['HTTP_' . str_replace("-", "_", $this->apiKeyHeader)])) {
234
+    if (!isset($_SERVER['HTTP_'.str_replace("-", "_", $this->apiKeyHeader)])) {
235 235
       $this->handle_response(RESTResponse::BAD_REQUEST, RESTAuth::API_KEY); // Exits.
236 236
     }
237 237
     $apiKey = $this->rest_model->getAPIKeyData(
238
-      $_SERVER['HTTP_' . str_replace("-", "_", $this->apiKeyHeader)]
238
+      $_SERVER['HTTP_'.str_replace("-", "_", $this->apiKeyHeader)]
239 239
     );
240 240
     if ($apiKey == null) {
241 241
       $this->handle_response(RESTResponse::UN_AUTHORIZED, RESTAuth::API_KEY); // Exits.
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
       }
252 252
       // Should we acyually Limit?
253 253
       if ($this->per_hour > 0) {
254
-        $client = hash('md5', $this->ci->input->ip_address() . "%" . $apiKey[$this->api_key_column]);
254
+        $client = hash('md5', $this->ci->input->ip_address()."%".$apiKey[$this->api_key_column]);
255 255
         $limitData = $this->rest_model->getLimitData($client, '_api_keyed_user');
256 256
         if ($limitData == null) {
257 257
           $limitData = [];
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
    * [get_authorization_header description]
335 335
    * @return [type] [description]
336 336
    */
337
-  private function get_authorization_header():?string {
337
+  private function get_authorization_header(): ?string {
338 338
     if (isset($_SERVER['Authorization'])) {
339 339
       return trim($_SERVER["Authorization"]);
340 340
     } else if (isset($_SERVER['HTTP_AUTHORIZATION'])) { //Nginx or fast CGI
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
    * [handle_response description]
356 356
    * @param int $code [description]
357 357
    */
358
-  private function handle_response(int $code, $auth=null):void {
358
+  private function handle_response(int $code, $auth = null):void {
359 359
     http_response_code($code);
360 360
     header("Content-Type: application/json");
361 361
     if (isset($this->ci->config->item('rest')['response_callbacks'][$code])) {
Please login to merge, or discard this patch.