Completed
Push — master ( ae9e36...135100 )
by Francis
01:28
created
libraries/RefactorCI.php 1 patch
Braces   +28 added lines, -9 removed lines patch added patch discarded remove patch
@@ -67,7 +67,9 @@  discard block
 block discarded – undo
67 67
     for ($x = 0; $x < count($array); $x++) {
68 68
       $refactor->switchPayload($array[$x]);
69 69
       $buff = $refactor->toArray();
70
-      if ($buff != null) $array[$x] = $buff;
70
+      if ($buff != null) {
71
+          $array[$x] = $buff;
72
+      }
71 73
     }
72 74
     return $array;
73 75
   }
@@ -78,7 +80,9 @@  discard block
 block discarded – undo
78 80
    */
79 81
   function run(array &$object, $ruleName):void
80 82
   {
81
-    if ($object == null) return;
83
+    if ($object == null) {
84
+        return;
85
+    }
82 86
     // Reolve Rules.
83 87
     if (is_scalar($ruleName)) {
84 88
       $rule = $this->ci->config->item("refactor_$ruleName");
@@ -88,7 +92,10 @@  discard block
 block discarded – undo
88 92
       $rule = is_array($ruleName) ? $ruleName : null;
89 93
     }
90 94
 
91
-    if ($rule == null) return; // No need to go further as rule doesn't exist.
95
+    if ($rule == null) {
96
+        return;
97
+    }
98
+    // No need to go further as rule doesn't exist.
92 99
     // Keep
93 100
     if (isset($rule['keep'])) {
94 101
       $keys = array_keys($object);
@@ -129,11 +136,15 @@  discard block
 block discarded – undo
129 136
             continue;
130 137
           }
131 138
           $object[$field] = $query->result_array()[0];
132
-          if (isset($data['refactor'])) $this->run($object[$field], $data['refactor']);
139
+          if (isset($data['refactor'])) {
140
+              $this->run($object[$field], $data['refactor']);
141
+          }
133 142
           continue;
134 143
         }
135 144
         if (isset($data['path'])) {
136
-          if ($ids == null) return;
145
+          if ($ids == null) {
146
+              return;
147
+          }
137 148
           $object[$field] = $ids;
138 149
           $this->ci->jsonp->parse($object[$field]);
139 150
           if (is_array($object[$field])) {
@@ -141,17 +152,23 @@  discard block
 block discarded – undo
141 152
             for ($x = 0; $x < count($refs); $x++) {
142 153
               $refs[$x] = $this->inflate_value($data['table'], $refs[$x]);
143 154
               // Recursion
144
-              if (isset($data['refactor'])) $this->run($refs[$x], $data['refactor']);
155
+              if (isset($data['refactor'])) {
156
+                  $this->run($refs[$x], $data['refactor']);
157
+              }
145 158
             }
146 159
           } else {
147 160
             $this->ci->jsonp->set($data['path'], $this->inflate_value($data['table'], $ids));
148 161
             // Recursion
149
-            if (isset($data['refactor'])) $this->run($this->ci->jsonp->get_reference($data['path']), $data['refactor']);
162
+            if (isset($data['refactor'])) {
163
+                $this->run($this->ci->jsonp->get_reference($data['path']), $data['refactor']);
164
+            }
150 165
           }
151 166
           return;
152 167
         }
153 168
         $object[$field] = [];
154
-        if ($ids == null) return;
169
+        if ($ids == null) {
170
+            return;
171
+        }
155 172
         foreach($ids as $id) {
156 173
           $this->ci->db->where($this->primaryKey, $id);
157 174
           $query = $this->ci->db->get($data['table']);
@@ -160,7 +177,9 @@  discard block
 block discarded – undo
160 177
           }
161 178
           $object[$field][] = $query->result_array()[0];
162 179
           // Recursion
163
-          if (isset($data['refactor'])) $this->run($object[$field][count($object[$field]) - 1], $data['refactor']);
180
+          if (isset($data['refactor'])) {
181
+              $this->run($object[$field][count($object[$field]) - 1], $data['refactor']);
182
+          }
164 183
         }
165 184
       }
166 185
     }
Please login to merge, or discard this patch.
libraries/RefactorPayload.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -50,7 +50,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.