Passed
Push — master ( 33dcd4...7a8481 )
by Francis
06:54
created
libraries/REST.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -137,16 +137,16 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
       }
363 363
       // Should we acyually Limit?
364 364
       if ($this->per_hour > 0) {
365
-        $client = hash('md5', $this->ci->input->ip_address() . "%" . $apiKey->{$this->api_key_column});
365
+        $client = hash('md5', $this->ci->input->ip_address()."%".$apiKey->{$this->api_key_column});
366 366
         $limitData = $this->rest_model->getLimitData($client, '_api_keyed_user');
367 367
         if ($limitData == null) {
368 368
           $limitData = [];
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
    * [get_authorization_header description]
449 449
    * @return [type] [description]
450 450
    */
451
-  private function get_authorization_header():?string
451
+  private function get_authorization_header(): ?string
452 452
   {
453 453
     if (isset($_SERVER['Authorization'])) {
454 454
       return trim($_SERVER["Authorization"]);
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
    * [handle_response description]
472 472
    * @param int $code [description]
473 473
    */
474
-  private function handle_response(int $code, $auth=null, ?string $errorReason=null):void
474
+  private function handle_response(int $code, $auth = null, ?string $errorReason = null):void
475 475
   {
476 476
     http_response_code($code);
477 477
     header("Content-Type: application/json");
Please login to merge, or discard this patch.