@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | |
12 | 12 | private $primaryKey; |
13 | 13 | |
14 | - function __construct($params=null) { |
|
15 | - $this->ci =& get_instance(); |
|
14 | + function __construct($params = null) { |
|
15 | + $this->ci = & get_instance(); |
|
16 | 16 | $this->ci->load->config("refactor", false, true); |
17 | 17 | $this->init($params == null ? [] : $params); |
18 | 18 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | // Unset |
28 | 28 | if (isset($rule['unset'])) { |
29 | - foreach($rule['unset'] as $key) { |
|
29 | + foreach ($rule['unset'] as $key) { |
|
30 | 30 | unset($object[$key]); |
31 | 31 | } |
32 | 32 | } |
@@ -41,21 +41,21 @@ discard block |
||
41 | 41 | |
42 | 42 | // Bools |
43 | 43 | if (isset($rule['bools'])) { |
44 | - foreach($rule['bools'] as $boolKey) { |
|
44 | + foreach ($rule['bools'] as $boolKey) { |
|
45 | 45 | $object[$boolKey] = $object[$boolKey] == 1 || $object[$boolKey] == 'true'; |
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | 49 | // Objects |
50 | 50 | if (isset($rule['objects'])) { |
51 | - foreach($rule['objects'] as $field => $data) { |
|
51 | + foreach ($rule['objects'] as $field => $data) { |
|
52 | 52 | $ids = json_decode($object[$field]); |
53 | 53 | if (is_scalar($ids)) { |
54 | 54 | // JSON Array wasn't supplied. Let's treat it as a scaler ID. |
55 | 55 | $this->ci->db->where($this->primaryKey, $ids); |
56 | 56 | $query = $this->ci->db->get($data['table']); |
57 | 57 | if ($query->num_rows() == 0) { |
58 | - $object[$field] = json_encode (json_decode ("{}")); |
|
58 | + $object[$field] = json_encode(json_decode("{}")); |
|
59 | 59 | continue; |
60 | 60 | } |
61 | 61 | $object[$field] = $query->result_array()[0]; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | continue; |
64 | 64 | } |
65 | 65 | $object[$field] = []; |
66 | - foreach($ids as $id) { |
|
66 | + foreach ($ids as $id) { |
|
67 | 67 | $this->ci->db->where($this->primaryKey, $id); |
68 | 68 | $query = $this->ci->db->get($data['table']); |
69 | 69 | if ($query->num_rows() == 0) { |
@@ -22,7 +22,10 @@ discard block |
||
22 | 22 | } |
23 | 23 | function run(array &$object, string $ruleName):void { |
24 | 24 | $rule = $this->ci->config->item("refactor_$ruleName"); |
25 | - if ($rule == null) return; // No need to go further as rule doesn't exist. |
|
25 | + if ($rule == null) { |
|
26 | + return; |
|
27 | + } |
|
28 | + // No need to go further as rule doesn't exist. |
|
26 | 29 | |
27 | 30 | // Unset |
28 | 31 | if (isset($rule['unset'])) { |
@@ -59,7 +62,9 @@ discard block |
||
59 | 62 | continue; |
60 | 63 | } |
61 | 64 | $object[$field] = $query->result_array()[0]; |
62 | - if (isset($data['refactor'])) $this->run($object[$field], $data['refactor']); |
|
65 | + if (isset($data['refactor'])) { |
|
66 | + $this->run($object[$field], $data['refactor']); |
|
67 | + } |
|
63 | 68 | continue; |
64 | 69 | } |
65 | 70 | $object[$field] = []; |
@@ -71,7 +76,9 @@ discard block |
||
71 | 76 | } |
72 | 77 | $object[$field][] = $query->result_array()[0]; |
73 | 78 | // Recursion |
74 | - if (isset($data['refactor'])) $this->run($object[$field][count($object[$field]) - 1], $data['refactor']); |
|
79 | + if (isset($data['refactor'])) { |
|
80 | + $this->run($object[$field][count($object[$field]) - 1], $data['refactor']); |
|
81 | + } |
|
75 | 82 | } |
76 | 83 | } |
77 | 84 | } |