@@ -50,7 +50,9 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function __get(string $key) |
| 52 | 52 | {
|
| 53 | - if (is_object($this->payload)) return $this->payload->$key; |
|
| 53 | + if (is_object($this->payload)) { |
|
| 54 | + return $this->payload->$key; |
|
| 55 | + } |
|
| 54 | 56 | return $this->payload[$key]; |
| 55 | 57 | } |
| 56 | 58 | /** |
@@ -61,7 +63,9 @@ discard block |
||
| 61 | 63 | public function __toString():string |
| 62 | 64 | {
|
| 63 | 65 | $buff = $refactor->toArray(); |
| 64 | - if ($buff != null) return json_encode($buff); |
|
| 66 | + if ($buff != null) { |
|
| 67 | + return json_encode($buff); |
|
| 68 | + } |
|
| 65 | 69 | |
| 66 | 70 | return json_encode($this->payload); |
| 67 | 71 | } |
@@ -101,7 +105,9 @@ discard block |
||
| 101 | 105 | */ |
| 102 | 106 | public function toArray():array |
| 103 | 107 | {
|
| 104 | - if (is_array($this->payload)) return $this->payload; |
|
| 108 | + if (is_array($this->payload)) { |
|
| 109 | + return $this->payload; |
|
| 110 | + } |
|
| 105 | 111 | return json_decode(json_encode($this->payload), true); |
| 106 | 112 | } |
| 107 | 113 | } |
@@ -94,7 +94,9 @@ discard block |
||
| 94 | 94 | for ($x = 0; $x < count($array); $x++) {
|
| 95 | 95 | $refactor->switchPayload($array[$x]); |
| 96 | 96 | $buff = $refactor->toArray(); |
| 97 | - if ($buff != null) $array[$x] = $buff; |
|
| 97 | + if ($buff != null) { |
|
| 98 | + $array[$x] = $buff; |
|
| 99 | + } |
|
| 98 | 100 | } |
| 99 | 101 | return $array; |
| 100 | 102 | } |
@@ -105,7 +107,9 @@ discard block |
||
| 105 | 107 | */ |
| 106 | 108 | function run(array &$object, $ruleName):void |
| 107 | 109 | {
|
| 108 | - if ($object == null) return; |
|
| 110 | + if ($object == null) { |
|
| 111 | + return; |
|
| 112 | + } |
|
| 109 | 113 | // Reolve Rules. |
| 110 | 114 | if (is_scalar($ruleName)) {
|
| 111 | 115 | $rule = $this->ci->config->item("refactor_$ruleName");
|
@@ -115,7 +119,10 @@ discard block |
||
| 115 | 119 | $rule = is_array($ruleName) ? $ruleName : null; |
| 116 | 120 | } |
| 117 | 121 | |
| 118 | - if ($rule == null) return; // No need to go further as rule doesn't exist. |
|
| 122 | + if ($rule == null) { |
|
| 123 | + return; |
|
| 124 | + } |
|
| 125 | + // No need to go further as rule doesn't exist. |
|
| 119 | 126 | // Keep |
| 120 | 127 | if (isset($rule['keep'])) {
|
| 121 | 128 | $keys = array_keys($object); |
@@ -156,11 +163,15 @@ discard block |
||
| 156 | 163 | continue; |
| 157 | 164 | } |
| 158 | 165 | $object[$field] = $query->result_array()[0]; |
| 159 | - if (isset($data['refactor'])) $this->run($object[$field], $data['refactor']); |
|
| 166 | + if (isset($data['refactor'])) { |
|
| 167 | + $this->run($object[$field], $data['refactor']); |
|
| 168 | + } |
|
| 160 | 169 | continue; |
| 161 | 170 | } |
| 162 | 171 | if (isset($data['path'])) {
|
| 163 | - if ($ids == null) return; |
|
| 172 | + if ($ids == null) { |
|
| 173 | + return; |
|
| 174 | + } |
|
| 164 | 175 | $object[$field] = $ids; |
| 165 | 176 | $this->ci->jsonp->parse($object[$field]); |
| 166 | 177 | if (is_array($object[$field])) {
|
@@ -168,17 +179,23 @@ discard block |
||
| 168 | 179 | for ($x = 0; $x < count($refs); $x++) {
|
| 169 | 180 | $refs[$x] = $this->inflate_value($data['table'], $refs[$x]); |
| 170 | 181 | // Recursion |
| 171 | - if (isset($data['refactor'])) $this->run($refs[$x], $data['refactor']); |
|
| 182 | + if (isset($data['refactor'])) { |
|
| 183 | + $this->run($refs[$x], $data['refactor']); |
|
| 184 | + } |
|
| 172 | 185 | } |
| 173 | 186 | } else {
|
| 174 | 187 | $this->ci->jsonp->set($data['path'], $this->inflate_value($data['table'], $ids)); |
| 175 | 188 | // Recursion |
| 176 | - if (isset($data['refactor'])) $this->run($this->ci->jsonp->get_reference($data['path']), $data['refactor']); |
|
| 189 | + if (isset($data['refactor'])) { |
|
| 190 | + $this->run($this->ci->jsonp->get_reference($data['path']), $data['refactor']); |
|
| 191 | + } |
|
| 177 | 192 | } |
| 178 | 193 | return; |
| 179 | 194 | } |
| 180 | 195 | $object[$field] = []; |
| 181 | - if ($ids == null) return; |
|
| 196 | + if ($ids == null) { |
|
| 197 | + return; |
|
| 198 | + } |
|
| 182 | 199 | foreach($ids as $id) {
|
| 183 | 200 | $this->ci->db->where($this->primaryKey, $id); |
| 184 | 201 | $query = $this->ci->db->get($data['table']); |
@@ -187,7 +204,9 @@ discard block |
||
| 187 | 204 | } |
| 188 | 205 | $object[$field][] = $query->result_array()[0]; |
| 189 | 206 | // Recursion |
| 190 | - if (isset($data['refactor'])) $this->run($object[$field][count($object[$field]) - 1], $data['refactor']); |
|
| 207 | + if (isset($data['refactor'])) { |
|
| 208 | + $this->run($object[$field][count($object[$field]) - 1], $data['refactor']); |
|
| 209 | + } |
|
| 191 | 210 | } |
| 192 | 211 | } |
| 193 | 212 | } |