@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | * @date 2020-04-10 |
27 | 27 | * @param [type] $params [description] |
28 | 28 | */ |
29 | - public function __construct($params=null) |
|
29 | + public function __construct($params = null) |
|
30 | 30 | { |
31 | - $this->ci =& get_instance(); |
|
31 | + $this->ci = & get_instance(); |
|
32 | 32 | $this->ci->load->config("refactor", false, true); |
33 | 33 | $this->ci->load->splint('francis94c/jsonp', '+JSONP', null, 'jsonp'); |
34 | 34 | |
@@ -36,16 +36,16 @@ discard block |
||
36 | 36 | |
37 | 37 | spl_autoload_register(function($name) { |
38 | 38 | if ($name == 'RefactorPayload') { |
39 | - require(APPPATH . 'splints/' . self::PACKAGE . '/libraries/RefactorPayload.php'); |
|
39 | + require(APPPATH.'splints/'.self::PACKAGE.'/libraries/RefactorPayload.php'); |
|
40 | 40 | return; |
41 | 41 | } |
42 | 42 | |
43 | - if (file_exists(APPPATH . "payloads/$name.php")) { |
|
44 | - require(APPPATH . "payloads/$name.php"); |
|
43 | + if (file_exists(APPPATH."payloads/$name.php")) { |
|
44 | + require(APPPATH."payloads/$name.php"); |
|
45 | 45 | return; |
46 | 46 | } |
47 | 47 | |
48 | - require(APPPATH . "libraries/refactor/$name.php"); // @deprecated |
|
48 | + require(APPPATH."libraries/refactor/$name.php"); // @deprecated |
|
49 | 49 | }); |
50 | 50 | } |
51 | 51 | /** |
@@ -133,24 +133,24 @@ discard block |
||
133 | 133 | } |
134 | 134 | // Bools |
135 | 135 | if (isset($rule['bools'])) { |
136 | - foreach($rule['bools'] as $boolKey) { |
|
136 | + foreach ($rule['bools'] as $boolKey) { |
|
137 | 137 | $object[$boolKey] = $object[$boolKey] == 1 || $object[$boolKey] == 'true'; |
138 | 138 | } |
139 | 139 | } |
140 | 140 | // Cast |
141 | - if (isset($rule['cast'])) { |
|
141 | + if (isset($rule['cast'])) { |
|
142 | 142 | $this->cast_fields($object, $rule); |
143 | 143 | } |
144 | 144 | // Inflate |
145 | 145 | if (isset($rule['inflate'])) { |
146 | - foreach($rule['inflate'] as $field => $data) { |
|
146 | + foreach ($rule['inflate'] as $field => $data) { |
|
147 | 147 | $ids = json_decode($object[$field], true); |
148 | 148 | if (is_scalar($ids)) { |
149 | 149 | // JSON Array wasn't supplied. Let's treat it as a scaler ID. |
150 | 150 | $this->ci->db->where($this->primaryKey, $ids); |
151 | 151 | $query = $this->ci->db->get($data['table']); |
152 | 152 | if ($query->num_rows() == 0) { |
153 | - $object[$field] = json_encode (json_decode ("{}")); |
|
153 | + $object[$field] = json_encode(json_decode("{}")); |
|
154 | 154 | continue; |
155 | 155 | } |
156 | 156 | $object[$field] = $query->result_array()[0]; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | } |
178 | 178 | $object[$field] = []; |
179 | 179 | if ($ids == null) return; |
180 | - foreach($ids as $id) { |
|
180 | + foreach ($ids as $id) { |
|
181 | 181 | $this->ci->db->where($this->primaryKey, $id); |
182 | 182 | $query = $this->ci->db->get($data['table']); |
183 | 183 | if ($query->num_rows() == 0) { |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * associative array. |
204 | 204 | */ |
205 | 205 | private function unset_values(array &$object, &$rule):void { |
206 | - foreach($rule['unset'] as $key) { |
|
206 | + foreach ($rule['unset'] as $key) { |
|
207 | 207 | unset($object[$key]); |
208 | 208 | } |
209 | 209 | } |