Completed
Push — master ( b895a8...a860d2 )
by Francis
01:34
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
     } else {
151 151
       $config = [];
152 152
     }
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 
165 165
     // Load Model.
166 166
     $this->ci->load->splint(self::PACKAGE, '*RESTModel', 'rest_model');
167
-    $this->rest_model =& $this->ci->rest_model;
167
+    $this->rest_model = & $this->ci->rest_model;
168 168
 
169 169
     $this->rest_model->init([
170 170
       'users_table'           => $config['basic_auth']['users_table'] ?? null,
@@ -266,14 +266,14 @@  discard block
 block discarded – undo
266 266
    */
267 267
   private function auth_proceed(bool $success, int $flags):bool
268 268
   {
269
-    if ($flags & self::AUTH_GRAVITY) return $success;
269
+    if ($flags&self::AUTH_GRAVITY) return $success;
270 270
     if ($success) {
271
-      if ($flags & self::AUTH_FINAL) {
271
+      if ($flags&self::AUTH_FINAL) {
272 272
         $this->authPreempted = true;
273 273
         return true;
274 274
       }
275 275
     } else {
276
-      return $flags & self::AUTH_PASSIVE ? true : false;
276
+      return $flags&self::AUTH_PASSIVE ? true : false;
277 277
     }
278 278
   }
279 279
 
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
   /**
336 336
    * [api_key_auth description]
337 337
    */
338
-  private function api_key_auth(int $flags=self::AUTH_GRAVITY):void
338
+  private function api_key_auth(int $flags = self::AUTH_GRAVITY):void
339 339
   {
340 340
     if (uri_string() == '')  return;
341 341
     $shouldProceed = $this->auth_proceed(false, $flags);
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
     }
383 383
     // Should we acyually Limit?
384 384
     if ($this->per_hour > 0) {
385
-      $client = hash('md5', $this->ci->input->ip_address() . "%" . $apiKey);
385
+      $client = hash('md5', $this->ci->input->ip_address()."%".$apiKey);
386 386
       $limitData = $this->rest_model->getLimitData($client, '_api_keyed_user');
387 387
       if ($limitData == null) {
388 388
         $limitData = [];
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
    * [get_authorization_header description]
467 467
    * @return [type] [description]
468 468
    */
469
-  private function get_authorization_header():?string
469
+  private function get_authorization_header(): ?string
470 470
   {
471 471
     if (isset($_SERVER['Authorization'])) {
472 472
       return trim($_SERVER["Authorization"]);
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
    * [handle_response description]
490 490
    * @param int $code [description]
491 491
    */
492
-  private function handle_response(int $code, $auth=null, ?string $errorReason=null):void
492
+  private function handle_response(int $code, $auth = null, ?string $errorReason = null):void
493 493
   {
494 494
     http_response_code($code);
495 495
     header("Content-Type: application/json");
Please login to merge, or discard this patch.