Passed
Push — master ( c60519...57a530 )
by Francis
01:29
created
models/RESTModel.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
    * @param  string $apiKey [description]
95 95
    * @return array          [description]
96 96
    */
97
-  public function getAPIKeyData(string $apiKey):?array {
97
+  public function getAPIKeyData(string $apiKey): ?array {
98 98
     // Preliminary Check.
99 99
     if ($this->api_key_table == null || $this->api_key_column == null) return null;
100 100
     // Query.
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
    * @param  string $group  [description]
121 121
    * @return [type]         [description]
122 122
    */
123
-  public function getLimitData(string $client, string $group):?array {
123
+  public function getLimitData(string $client, string $group): ?array {
124 124
     $sql = 'SELECT count, start, (`start` + INTERVAL (1 - TIMESTAMPDIFF(HOUR, UTC_TIMESTAMP(), NOW())) HOUR) AS reset_epoch FROM rest_api_rate_limit WHERE client = ? AND _group = ?';
125 125
     $query = $this->db->query($sql, [$client, $group]);
126 126
     if (!is_scalar($query) && $query->num_rows() > 0) return $query->result_array()[0];
Please login to merge, or discard this patch.
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -81,10 +81,14 @@  discard block
 block discarded – undo
81 81
       $this->db->or_where($this->users_username_column, $username);
82 82
     }
83 83
     $query = $this->db->get();
84
-    if ($query->num_rows() == 0) return false;
84
+    if ($query->num_rows() == 0) {
85
+     return false;
86
+    }
85 87
     // Authenticate.
86 88
     if (password_verify($password, $query->result()[0]->{$this->users_password_column})) {
87
-      if ($this->users_id_column != null) $context->userId = $query->result()[0]->{$this->users_id_column};
89
+      if ($this->users_id_column != null) {
90
+       $context->userId = $query->result()[0]->{$this->users_id_column};
91
+      }
88 92
       return true;
89 93
     }
90 94
     return false;
@@ -96,15 +100,21 @@  discard block
 block discarded – undo
96 100
    */
97 101
   public function getAPIKeyData(string $apiKey):?array {
98 102
     // Preliminary Check.
99
-    if ($this->api_key_table == null || $this->api_key_column == null) return null;
103
+    if ($this->api_key_table == null || $this->api_key_column == null) {
104
+     return null;
105
+    }
100 106
     // Query.
101 107
     $this->db->select($this->api_key_column);
102
-    if ($this->api_key_limit_column != null) $this->db->select($this->api_key_limit_column);
108
+    if ($this->api_key_limit_column != null) {
109
+     $this->db->select($this->api_key_limit_column);
110
+    }
103 111
     $this->db->from($this->api_key_table);
104 112
     $this->db->where($this->api_key_column, $apiKey);
105 113
     $query = $this->db->get();
106 114
     // Process Result.
107
-    if ($query->num_rows() > 0) return $query->result_array()[0];
115
+    if ($query->num_rows() > 0) {
116
+     return $query->result_array()[0];
117
+    }
108 118
     return null;
109 119
   }
110 120
   /**
@@ -123,7 +133,9 @@  discard block
 block discarded – undo
123 133
   public function getLimitData(string $client, string $group):?array {
124 134
     $sql = 'SELECT count, start, (`start` + INTERVAL (1 - TIMESTAMPDIFF(HOUR, UTC_TIMESTAMP(), NOW())) HOUR) AS reset_epoch FROM rest_api_rate_limit WHERE client = ? AND _group = ?';
125 135
     $query = $this->db->query($sql, [$client, $group]);
126
-    if (!is_scalar($query) && $query->num_rows() > 0) return $query->result_array()[0];
136
+    if (!is_scalar($query) && $query->num_rows() > 0) {
137
+     return $query->result_array()[0];
138
+    }
127 139
     return null;
128 140
   }
129 141
   /**
Please login to merge, or discard this patch.
phpunit/RESTTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
    */
25 25
   public static function setUpBeforeClass(): void {
26 26
     echo "IN TEST";
27
-    self::$ci =& get_instance();
27
+    self::$ci = & get_instance();
28 28
     self::$ci->load->database('mysqli://root@localhost/test_db');
29 29
     self::$ci->load->helper("url");
30
-    $queries = explode("#@@@", file_get_contents(FCPATH . 'application/splints/' . self::PACKAGE . '/phpunit/database.sql'));
30
+    $queries = explode("#@@@", file_get_contents(FCPATH.'application/splints/'.self::PACKAGE.'/phpunit/database.sql'));
31 31
     self::assertTrue(count($queries) > 0);
32 32
     self::$ci->load->database();
33 33
     foreach ($queries as $query) {
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     // However, for the purpose of this test, we are going to Hack Code CodeIgniter
44 44
     // with a Splint Config variable to allow us load config files from where
45 45
     // ever we want. This happens below.
46
-    self::$ci->load->add_package_path(APPPATH . 'splints/' . self::PACKAGE . "/phpunit/");
46
+    self::$ci->load->add_package_path(APPPATH.'splints/'.self::PACKAGE."/phpunit/");
47 47
     //self::$ci->config->set_item('st_config_path_prefix', '../splints/' . self::PACKAGE . "/phpunit/config/");
48 48
   }
49 49
   /**
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     // Simulate Basic Authorization
56 56
     $_SERVER['PHP_AUTH_USER'] = "francis94c";
57 57
     $_SERVER['PHP_AUTH_PW'] = "0123456789";
58
-    self::$ci->load->splint(self::PACKAGE, '+REST', null, 'rest_' . $this->obj_count++);
58
+    self::$ci->load->splint(self::PACKAGE, '+REST', null, 'rest_'.$this->obj_count++);
59 59
     $this->assertEquals(1, self::$ci->{'rest_'.($this->obj_count - 1)}->userId);
60 60
   }
61 61
   /**
Please login to merge, or discard this patch.
phpunit/config/rest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,19 +9,19 @@
 block discarded – undo
9 9
 
10 10
 $config['auth_callbacks'] = [
11 11
 
12
-  RESTAuth::CUSTOM('X-APP-ID')    => function (&$context, $value):bool {
12
+  RESTAuth::CUSTOM('X-APP-ID')    => function(&$context, $value):bool {
13 13
     return true;
14 14
   },
15 15
 
16
-  RESTAuth::CUSTOM('X-DEVICE-ID') => function (&$context, $value):bool {
16
+  RESTAuth::CUSTOM('X-DEVICE-ID') => function(&$context, $value):bool {
17 17
     return true;
18 18
   },
19 19
 
20
-  RESTAuth::BEARER                => function (&$context, $token):bool {
20
+  RESTAuth::BEARER                => function(&$context, $token):bool {
21 21
     return true;
22 22
   },
23 23
 
24
-  RESTAuth::OAUTH2                => function (&$context, $token):bool {
24
+  RESTAuth::OAUTH2                => function(&$context, $token):bool {
25 25
     return true;
26 26
   }
27 27
 
Please login to merge, or discard this patch.