Completed
Push — master ( 6cc37f...3f8b72 )
by Francis
02:00
created
phpunit/RefactorTest.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
    * @covers JWT::__construct
21 21
    */
22 22
   public static function setUpBeforeClass(): void {
23
-    self::$ci =& get_instance();
23
+    self::$ci = & get_instance();
24 24
   }
25 25
   /**
26 26
    * [testLoadPackage description]
Please login to merge, or discard this patch.
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -3,54 +3,54 @@
 block discarded – undo
3 3
 use PHPUnit\Framework\TestCase;
4 4
 
5 5
 class RefactorTest extends TestCase {
6
-  /**
7
-   * Code Igniter Instance.
8
-   * @var object
9
-   */
10
-  private static $ci;
11
-  /**
12
-   * Package name for simplicity
13
-   * @var string
14
-   */
15
-  private const PACKAGE = "francis94c/refactor-ci";
6
+    /**
7
+     * Code Igniter Instance.
8
+     * @var object
9
+     */
10
+    private static $ci;
11
+    /**
12
+     * Package name for simplicity
13
+     * @var string
14
+     */
15
+    private const PACKAGE = "francis94c/refactor-ci";
16 16
 
17
-  /**
18
-   * Prerquisites for the Unit Tests.
19
-   *
20
-   * @covers JWT::__construct
21
-   */
22
-  public static function setUpBeforeClass(): void {
17
+    /**
18
+     * Prerquisites for the Unit Tests.
19
+     *
20
+     * @covers JWT::__construct
21
+     */
22
+    public static function setUpBeforeClass(): void {
23 23
     self::$ci =& get_instance();
24
-  }
25
-  /**
26
-   * [testLoadPackage description]
27
-   */
28
-  public function testLoadPackage():void {
24
+    }
25
+    /**
26
+     * [testLoadPackage description]
27
+     */
28
+    public function testLoadPackage():void {
29 29
     self::$ci->load->package(self::PACKAGE);
30 30
     $this->assertTrue(isset(self::$ci->refactor));
31
-  }
32
-  /**
33
-   * [testDirectUnsetRule description]
34
-   *
35
-   * @depends testLoadPackage
36
-   */
37
-  public function testDirectUnsetRule():void {
31
+    }
32
+    /**
33
+     * [testDirectUnsetRule description]
34
+     *
35
+     * @depends testLoadPackage
36
+     */
37
+    public function testDirectUnsetRule():void {
38 38
     $payload = [
39
-      'name'     => 'collins',
40
-      'pc_brand' => 'HP',
41
-      'phone'    => '+2349086756453',
42
-      'school'   => 'Delloite',
43
-      'company'  => 'Google'
39
+        'name'     => 'collins',
40
+        'pc_brand' => 'HP',
41
+        'phone'    => '+2349086756453',
42
+        'school'   => 'Delloite',
43
+        'company'  => 'Google'
44 44
     ];
45 45
     $rule = [
46
-      'unset' => [
46
+        'unset' => [
47 47
         'school',
48 48
         'phone'
49
-      ]
49
+        ]
50 50
     ];
51 51
     self::$ci->refactor->run($payload, $rule);
52 52
     $this->assertFalse(isset($payload['school']));
53 53
     $this->assertFalse(isset($payload['phone']));
54 54
     $this->assertTrue(isset($payload['company']));
55
-  }
55
+    }
56 56
 }
Please login to merge, or discard this patch.
libraries/RefactorCI.php 3 patches
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.
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -4,230 +4,230 @@
 block discarded – undo
4 4
 class RefactorCI
5 5
 {
6 6
 
7
-  /**
8
-   * [private description]
9
-   * @var [type]
10
-   */
11
-  private $ci;
12
-  /**
13
-   * [private description]
14
-   * @var [type]
15
-   */
16
-  private $primaryKey;
17
-  /**
18
-   * [public description]
19
-   * @var [type]
20
-   */
21
-  public const PACKAGE = 'francis94c/refactor-ci';
7
+    /**
8
+     * [private description]
9
+     * @var [type]
10
+     */
11
+    private $ci;
12
+    /**
13
+     * [private description]
14
+     * @var [type]
15
+     */
16
+    private $primaryKey;
17
+    /**
18
+     * [public description]
19
+     * @var [type]
20
+     */
21
+    public const PACKAGE = 'francis94c/refactor-ci';
22 22
 
23
-  function __construct($params=null)
24
-  {
23
+    function __construct($params=null)
24
+    {
25 25
     $this->ci =& get_instance();
26 26
     $this->ci->load->config("refactor", false, true);
27 27
     $this->ci->load->splint('francis94c/jsonp', '+JSONP', null, 'jsonp');
28 28
     $this->init($params == null ? [] : $params);
29 29
 
30 30
     spl_autoload_register(function($name) {
31
-      if ($name == 'RefactorPayload') {
31
+        if ($name == 'RefactorPayload') {
32 32
         require(APPPATH . 'splints/' . self::PACKAGE . '/libraries/RefactorPayload.php');
33 33
         return;
34
-      }
34
+        }
35 35
 
36
-      $oldPath = set_include_path(APPPATH . 'libraries/refactor/');
36
+        $oldPath = set_include_path(APPPATH . 'libraries/refactor/');
37 37
 
38
-      require("$name.php");
38
+        require("$name.php");
39 39
 
40
-      set_include_path($oldPath);
40
+        set_include_path($oldPath);
41 41
     });
42
-  }
43
-  /**
44
-   * [init description]
45
-   * @date  2019-11-02
46
-   * @param array      $params [description]
47
-   */
48
-  public function init(array $params):void
49
-  {
42
+    }
43
+    /**
44
+     * [init description]
45
+     * @date  2019-11-02
46
+     * @param array      $params [description]
47
+     */
48
+    public function init(array $params):void
49
+    {
50 50
     $this->primaryKey = $params['primary_key'] ?? 'id';
51
-  }
52
-  /**
53
-   * [load description]
54
-   * @date   2019-11-02
55
-   * @return RefactorCI [description]
56
-   */
57
-  public function load($class):RefactorCI
58
-  {
51
+    }
52
+    /**
53
+     * [load description]
54
+     * @date   2019-11-02
55
+     * @return RefactorCI [description]
56
+     */
57
+    public function load($class):RefactorCI
58
+    {
59 59
     require_once(APPPATH.'libraries/refactor/'.$class.'.php');
60 60
     return $this;
61
-  }
62
-  /**
63
-   * [payload description]
64
-   * @date   2019-11-02
65
-   * @param  string     $class  [description]
66
-   * @param  [type]     $object [description]
67
-   * @return [type]             [description]
68
-   */
69
-  public function payload(string $class, $object)
70
-  {
61
+    }
62
+    /**
63
+     * [payload description]
64
+     * @date   2019-11-02
65
+     * @param  string     $class  [description]
66
+     * @param  [type]     $object [description]
67
+     * @return [type]             [description]
68
+     */
69
+    public function payload(string $class, $object)
70
+    {
71 71
     return (new $class($object))->toArray();
72
-  }
73
-  /**
74
-   * [array description]
75
-   * @date   2019-11-02
76
-   * @param  string     $class [description]
77
-   * @param  array      $array [description]
78
-   * @return array             [description]
79
-   */
80
-  public function array(string $class, array $array):array
81
-  {
72
+    }
73
+    /**
74
+     * [array description]
75
+     * @date   2019-11-02
76
+     * @param  string     $class [description]
77
+     * @param  array      $array [description]
78
+     * @return array             [description]
79
+     */
80
+    public function array(string $class, array $array):array
81
+    {
82 82
     $refactor = new $class();
83 83
     $buff;
84 84
     for ($x = 0; $x < count($array); $x++) {
85
-      $refactor->switchPayload($array[$x]);
86
-      $buff = $refactor->toArray();
87
-      if ($buff != null) $array[$x] = $buff;
85
+        $refactor->switchPayload($array[$x]);
86
+        $buff = $refactor->toArray();
87
+        if ($buff != null) $array[$x] = $buff;
88 88
     }
89 89
     return $array;
90
-  }
91
-  /**
92
-   * [run description]
93
-   * @param array|string  $object   [description]
94
-   * @param string        $ruleName [description]
95
-   */
96
-  function run(array &$object, $ruleName):void
97
-  {
90
+    }
91
+    /**
92
+     * [run description]
93
+     * @param array|string  $object   [description]
94
+     * @param string        $ruleName [description]
95
+     */
96
+    function run(array &$object, $ruleName):void
97
+    {
98 98
     if ($object == null) return;
99 99
     // Reolve Rules.
100 100
     if (is_scalar($ruleName)) {
101
-      $rule = $this->ci->config->item("refactor_$ruleName");
101
+        $rule = $this->ci->config->item("refactor_$ruleName");
102 102
     } else {
103
-      // Rule was probablt passed in as an array (associative) and we support
104
-      // that.
105
-      $rule = is_array($ruleName) ? $ruleName : null;
103
+        // Rule was probablt passed in as an array (associative) and we support
104
+        // that.
105
+        $rule = is_array($ruleName) ? $ruleName : null;
106 106
     }
107 107
 
108 108
     if ($rule == null) return; // No need to go further as rule doesn't exist.
109 109
     // Keep
110 110
     if (isset($rule['keep'])) {
111
-      $keys = array_keys($object);
112
-      for ($x = 0; $x < count($object); $x++) {
111
+        $keys = array_keys($object);
112
+        for ($x = 0; $x < count($object); $x++) {
113 113
         if (!in_array($keys[$X], $rule['keep'])) {
114
-          unset($object[$keys[$x]]);
114
+            unset($object[$keys[$x]]);
115
+        }
115 116
         }
116
-      }
117 117
     }
118 118
     // Unset
119 119
     if (isset($rule['unset'])) {
120
-      $this->unset_values($object, $rule);
120
+        $this->unset_values($object, $rule);
121 121
     }
122 122
     // Replace
123 123
     if (isset($rule['replace'])) {
124
-      $this->replace_fields($object, $rule);
124
+        $this->replace_fields($object, $rule);
125 125
     }
126 126
     // Bools
127 127
     if (isset($rule['bools'])) {
128
-      foreach($rule['bools'] as $boolKey) {
128
+        foreach($rule['bools'] as $boolKey) {
129 129
         $object[$boolKey] = $object[$boolKey] == 1 || $object[$boolKey] == 'true';
130
-      }
130
+        }
131 131
     }
132 132
     // Cast
133 133
     if (isset($rule['cast']))  {
134
-      $this->cast_fields($object, $rule);
134
+        $this->cast_fields($object, $rule);
135 135
     }
136 136
     // Inflate
137 137
     if (isset($rule['inflate'])) {
138
-      foreach($rule['inflate'] as $field => $data) {
138
+        foreach($rule['inflate'] as $field => $data) {
139 139
         $ids = json_decode($object[$field], true);
140 140
         if (is_scalar($ids)) {
141
-          // JSON Array wasn't supplied. Let's treat it as a scaler ID.
142
-          $this->ci->db->where($this->primaryKey, $ids);
143
-          $query = $this->ci->db->get($data['table']);
144
-          if ($query->num_rows() == 0) {
141
+            // JSON Array wasn't supplied. Let's treat it as a scaler ID.
142
+            $this->ci->db->where($this->primaryKey, $ids);
143
+            $query = $this->ci->db->get($data['table']);
144
+            if ($query->num_rows() == 0) {
145 145
             $object[$field] = json_encode (json_decode ("{}"));
146 146
             continue;
147
-          }
148
-          $object[$field] = $query->result_array()[0];
149
-          if (isset($data['refactor'])) $this->run($object[$field], $data['refactor']);
150
-          continue;
147
+            }
148
+            $object[$field] = $query->result_array()[0];
149
+            if (isset($data['refactor'])) $this->run($object[$field], $data['refactor']);
150
+            continue;
151 151
         }
152 152
         if (isset($data['path'])) {
153
-          if ($ids == null) return;
154
-          $object[$field] = $ids;
155
-          $this->ci->jsonp->parse($object[$field]);
156
-          if (is_array($object[$field])) {
153
+            if ($ids == null) return;
154
+            $object[$field] = $ids;
155
+            $this->ci->jsonp->parse($object[$field]);
156
+            if (is_array($object[$field])) {
157 157
             $refs = $this->ci->jsonp->get_reference($data['path']);
158 158
             for ($x = 0; $x < count($refs); $x++) {
159
-              $refs[$x] = $this->inflate_value($data['table'], $refs[$x]);
160
-              // Recursion
161
-              if (isset($data['refactor'])) $this->run($refs[$x], $data['refactor']);
159
+                $refs[$x] = $this->inflate_value($data['table'], $refs[$x]);
160
+                // Recursion
161
+                if (isset($data['refactor'])) $this->run($refs[$x], $data['refactor']);
162 162
             }
163
-          } else {
163
+            } else {
164 164
             $this->ci->jsonp->set($data['path'], $this->inflate_value($data['table'], $ids));
165 165
             // Recursion
166 166
             if (isset($data['refactor'])) $this->run($this->ci->jsonp->get_reference($data['path']), $data['refactor']);
167
-          }
168
-          return;
167
+            }
168
+            return;
169 169
         }
170 170
         $object[$field] = [];
171 171
         if ($ids == null) return;
172 172
         foreach($ids as $id) {
173
-          $this->ci->db->where($this->primaryKey, $id);
174
-          $query = $this->ci->db->get($data['table']);
175
-          if ($query->num_rows() == 0) {
173
+            $this->ci->db->where($this->primaryKey, $id);
174
+            $query = $this->ci->db->get($data['table']);
175
+            if ($query->num_rows() == 0) {
176 176
             continue;
177
-          }
178
-          $object[$field][] = $query->result_array()[0];
179
-          // Recursion
180
-          if (isset($data['refactor'])) $this->run($object[$field][count($object[$field]) - 1], $data['refactor']);
177
+            }
178
+            $object[$field][] = $query->result_array()[0];
179
+            // Recursion
180
+            if (isset($data['refactor'])) $this->run($object[$field][count($object[$field]) - 1], $data['refactor']);
181
+        }
181 182
         }
182
-      }
183 183
     }
184
-  }
185
-  private function inflate_value(string $table, $value)
186
-  {
184
+    }
185
+    private function inflate_value(string $table, $value)
186
+    {
187 187
     $this->ci->db->where($this->primaryKey, $value);
188 188
     $query = $this->ci->db->get($table);
189 189
     return $query->num_rows() > 0 ? $query->result_array()[0] : null;
190
-  }
191
-  /**
192
-   * [unset_values description]
193
-   * @param array  $object Object to Refactor.
194
-   * @param array  $rule   Rule data, containing keys to unset in  the given
195
-   *                       associative array.
196
-   */
197
-  private function unset_values(array &$object, &$rule):void {
190
+    }
191
+    /**
192
+     * [unset_values description]
193
+     * @param array  $object Object to Refactor.
194
+     * @param array  $rule   Rule data, containing keys to unset in  the given
195
+     *                       associative array.
196
+     */
197
+    private function unset_values(array &$object, &$rule):void {
198 198
     foreach($rule['unset'] as $key) {
199
-      unset($object[$key]);
200
-    }
201
-  }
202
-  /**
203
-   * [replace_fields description]
204
-   * @param array  $object [description]
205
-   * @param [type] $rule   [description]
206
-   */
207
-  private function replace_fields(array &$object, &$rule):void
208
-  {
199
+        unset($object[$key]);
200
+    }
201
+    }
202
+    /**
203
+     * [replace_fields description]
204
+     * @param array  $object [description]
205
+     * @param [type] $rule   [description]
206
+     */
207
+    private function replace_fields(array &$object, &$rule):void
208
+    {
209 209
     foreach ($rule['replace'] as $oldKey => $newKey) {
210
-      $object[$newKey] = $object[$oldKey];
211
-      unset($object[$oldKey]);
212
-    }
213
-  }
214
-  /**
215
-   * [cast_fields description]
216
-   * @param array  $object [description]
217
-   * @param [type] $rule   [description]
218
-   */
219
-  private function cast_fields(array &$object, &$rule):void
220
-  {
210
+        $object[$newKey] = $object[$oldKey];
211
+        unset($object[$oldKey]);
212
+    }
213
+    }
214
+    /**
215
+     * [cast_fields description]
216
+     * @param array  $object [description]
217
+     * @param [type] $rule   [description]
218
+     */
219
+    private function cast_fields(array &$object, &$rule):void
220
+    {
221 221
     foreach ($rule['cast'] as $key => $type) {
222
-      switch ($type) {
222
+        switch ($type) {
223 223
         case 'int':
224 224
           $object[$key] = (int) $object[$key];
225
-          break;
225
+            break;
226 226
         case 'string':
227 227
           $object[$key] = (string) $object[$key];
228
-          break;
229
-      }
228
+            break;
229
+        }
230
+    }
230 231
     }
231
-  }
232 232
 }
233 233
 ?>
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -20,20 +20,20 @@  discard block
 block discarded – undo
20 20
    */
21 21
   public const PACKAGE = 'francis94c/refactor-ci';
22 22
 
23
-  function __construct($params=null)
23
+  function __construct($params = null)
24 24
   {
25
-    $this->ci =& get_instance();
25
+    $this->ci = & get_instance();
26 26
     $this->ci->load->config("refactor", false, true);
27 27
     $this->ci->load->splint('francis94c/jsonp', '+JSONP', null, 'jsonp');
28 28
     $this->init($params == null ? [] : $params);
29 29
 
30 30
     spl_autoload_register(function($name) {
31 31
       if ($name == 'RefactorPayload') {
32
-        require(APPPATH . 'splints/' . self::PACKAGE . '/libraries/RefactorPayload.php');
32
+        require(APPPATH.'splints/'.self::PACKAGE.'/libraries/RefactorPayload.php');
33 33
         return;
34 34
       }
35 35
 
36
-      $oldPath = set_include_path(APPPATH . 'libraries/refactor/');
36
+      $oldPath = set_include_path(APPPATH.'libraries/refactor/');
37 37
 
38 38
       require("$name.php");
39 39
 
@@ -125,24 +125,24 @@  discard block
 block discarded – undo
125 125
     }
126 126
     // Bools
127 127
     if (isset($rule['bools'])) {
128
-      foreach($rule['bools'] as $boolKey) {
128
+      foreach ($rule['bools'] as $boolKey) {
129 129
         $object[$boolKey] = $object[$boolKey] == 1 || $object[$boolKey] == 'true';
130 130
       }
131 131
     }
132 132
     // Cast
133
-    if (isset($rule['cast']))  {
133
+    if (isset($rule['cast'])) {
134 134
       $this->cast_fields($object, $rule);
135 135
     }
136 136
     // Inflate
137 137
     if (isset($rule['inflate'])) {
138
-      foreach($rule['inflate'] as $field => $data) {
138
+      foreach ($rule['inflate'] as $field => $data) {
139 139
         $ids = json_decode($object[$field], true);
140 140
         if (is_scalar($ids)) {
141 141
           // JSON Array wasn't supplied. Let's treat it as a scaler ID.
142 142
           $this->ci->db->where($this->primaryKey, $ids);
143 143
           $query = $this->ci->db->get($data['table']);
144 144
           if ($query->num_rows() == 0) {
145
-            $object[$field] = json_encode (json_decode ("{}"));
145
+            $object[$field] = json_encode(json_decode("{}"));
146 146
             continue;
147 147
           }
148 148
           $object[$field] = $query->result_array()[0];
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         }
170 170
         $object[$field] = [];
171 171
         if ($ids == null) return;
172
-        foreach($ids as $id) {
172
+        foreach ($ids as $id) {
173 173
           $this->ci->db->where($this->primaryKey, $id);
174 174
           $query = $this->ci->db->get($data['table']);
175 175
           if ($query->num_rows() == 0) {
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
    *                       associative array.
196 196
    */
197 197
   private function unset_values(array &$object, &$rule):void {
198
-    foreach($rule['unset'] as $key) {
198
+    foreach ($rule['unset'] as $key) {
199 199
       unset($object[$key]);
200 200
     }
201 201
   }
Please login to merge, or discard this patch.
libraries/RefactorPayload.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
    * @date  2019-11-02
12 12
    * @param array      $payload [description]
13 13
    */
14
-  public function __construct($payload=[])
14
+  public function __construct($payload = [])
15 15
   {
16 16
     $this->payload = $payload;
17 17
   }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
    */
70 70
   public function switchPayload(&$payload):void
71 71
   {
72
-    $this->payload =& $payload;
72
+    $this->payload = & $payload;
73 73
   }
74 74
   /**
75 75
    * [toArray description]
Please login to merge, or discard this patch.
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -5,104 +5,104 @@
 block discarded – undo
5 5
 
6 6
 class RefactorPayload
7 7
 {
8
-  protected $payload;
9
-  /**
10
-   * [__construct description]
11
-   * @date  2019-11-02
12
-   * @param array      $payload [description]
13
-   */
14
-  public function __construct($payload=[])
15
-  {
8
+    protected $payload;
9
+    /**
10
+     * [__construct description]
11
+     * @date  2019-11-02
12
+     * @param array      $payload [description]
13
+     */
14
+    public function __construct($payload=[])
15
+    {
16 16
     $this->payload = $payload;
17
-  }
18
-  /**
19
-   * [__set description]
20
-   * @date  2019-11-02
21
-   * @param string     $key   [description]
22
-   * @param [type]     $value [description]
23
-   */
24
-  public function __set(string $key, $value):void
25
-  {
17
+    }
18
+    /**
19
+     * [__set description]
20
+     * @date  2019-11-02
21
+     * @param string     $key   [description]
22
+     * @param [type]     $value [description]
23
+     */
24
+    public function __set(string $key, $value):void
25
+    {
26 26
     if (is_object($this->payload)) {
27
-      $this->payload->$key = $value;
28
-      return;
27
+        $this->payload->$key = $value;
28
+        return;
29 29
     }
30 30
     $this->payload[$key] = $value;
31
-  }
32
-  /**
33
-   * [__unset description]
34
-   * @date  2019-11-02
35
-   * @param string     $key [description]
36
-   */
37
-  public function __unset(string $key):void
38
-  {
31
+    }
32
+    /**
33
+     * [__unset description]
34
+     * @date  2019-11-02
35
+     * @param string     $key [description]
36
+     */
37
+    public function __unset(string $key):void
38
+    {
39 39
     if (is_object($this->payload)) {
40
-      unset($this->payload->$key);
41
-      return;
40
+        unset($this->payload->$key);
41
+        return;
42 42
     }
43 43
     unset($this->payload[$key]);
44
-  }
45
-  /**
46
-   * [__get description]
47
-   * @date   2019-11-02
48
-   * @param  string     $key [description]
49
-   * @return [type]          [description]
50
-   */
51
-  public function __get(string $key)
52
-  {
44
+    }
45
+    /**
46
+     * [__get description]
47
+     * @date   2019-11-02
48
+     * @param  string     $key [description]
49
+     * @return [type]          [description]
50
+     */
51
+    public function __get(string $key)
52
+    {
53 53
     if (is_object($this->payload)) return $this->payload->$key;
54 54
     return $this->payload[$key];
55
-  }
56
-  /**
57
-   * [__toString description]
58
-   * @date   2019-11-03
59
-   * @return string     [description]
60
-   */
61
-  public function __toString():string
62
-  {
55
+    }
56
+    /**
57
+     * [__toString description]
58
+     * @date   2019-11-03
59
+     * @return string     [description]
60
+     */
61
+    public function __toString():string
62
+    {
63 63
     $buff = $refactor->toArray();
64 64
     if ($buff != null) return json_encode($buff);
65 65
 
66 66
     return json_encode($this->payload);
67
-  }
68
-  /**
69
-   * [__debugInfo description]
70
-   * @date   2019-11-03
71
-   * @return [type]     [description]
72
-   */
73
-  public function __debugInfo():array
74
-  {
67
+    }
68
+    /**
69
+     * [__debugInfo description]
70
+     * @date   2019-11-03
71
+     * @return [type]     [description]
72
+     */
73
+    public function __debugInfo():array
74
+    {
75 75
     return [
76
-      'payload' => $this->payload
76
+        'payload' => $this->payload
77 77
     ];
78
-  }
79
-  /**
80
-   * [setPayload description]
81
-   * @date  2019-11-02
82
-   * @param [type]     $payload [description]
83
-   */
84
-  public function setPayload($payload):void
85
-  {
78
+    }
79
+    /**
80
+     * [setPayload description]
81
+     * @date  2019-11-02
82
+     * @param [type]     $payload [description]
83
+     */
84
+    public function setPayload($payload):void
85
+    {
86 86
     $this->payload = $payload;
87
-  }
88
-  /**
89
-   * [set_payload description]
90
-   * @date  2019-11-02
91
-   * @param array      $payload [description]
92
-   */
93
-  public function switchPayload(&$payload):void
94
-  {
87
+    }
88
+    /**
89
+     * [set_payload description]
90
+     * @date  2019-11-02
91
+     * @param array      $payload [description]
92
+     */
93
+    public function switchPayload(&$payload):void
94
+    {
95 95
     $this->payload =& $payload;
96
-  }
97
-  /**
98
-   * [toArray description]
99
-   * @date   2019-11-02
100
-   * @return array      [description]
101
-   */
102
-  public function toArray():array
103
-  {
96
+    }
97
+    /**
98
+     * [toArray description]
99
+     * @date   2019-11-02
100
+     * @return array      [description]
101
+     */
102
+    public function toArray():array
103
+    {
104 104
     if (is_array($this->payload)) return $this->payload;
105 105
     return json_decode(json_encode($this->payload), true);
106
-  }
106
+    }
107 107
 }
108 108
 ?>
Please login to merge, or discard this 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.
libraries/RefactorArray.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -3,55 +3,55 @@
 block discarded – undo
3 3
 
4 4
 class RefactorArray implements ArrayAccess, Countable
5 5
 {
6
-  /**
7
-   * [private description]
8
-   * @var [type]
9
-   */
10
-  private $data = array();
11
-  /**
12
-   * [offsetSet description]
13
-   * @date  2019-11-02
14
-   * @param [type]     $offset [description]
15
-   * @param [type]     $value  [description]
16
-   */
17
-  public function offsetSet($offset, $value)
18
-  {
6
+    /**
7
+     * [private description]
8
+     * @var [type]
9
+     */
10
+    private $data = array();
11
+    /**
12
+     * [offsetSet description]
13
+     * @date  2019-11-02
14
+     * @param [type]     $offset [description]
15
+     * @param [type]     $value  [description]
16
+     */
17
+    public function offsetSet($offset, $value)
18
+    {
19 19
     $this->data[$offset] = $value;
20
-  }
21
-  /**
22
-   * [offsetExists description]
23
-   * @date  2019-11-02
24
-   * @param [type]     $offset [description]
25
-   */
26
-  public function offsetExists($offset)
27
-  {
20
+    }
21
+    /**
22
+     * [offsetExists description]
23
+     * @date  2019-11-02
24
+     * @param [type]     $offset [description]
25
+     */
26
+    public function offsetExists($offset)
27
+    {
28 28
     return isset($this->data[$offset]);
29
-  }
30
-  /**
31
-   * [offsetUnset description]
32
-   * @date  2019-11-02
33
-   * @param [type]     $offset [description]
34
-   */
35
-  public function offsetUnset($offset)
36
-  {
29
+    }
30
+    /**
31
+     * [offsetUnset description]
32
+     * @date  2019-11-02
33
+     * @param [type]     $offset [description]
34
+     */
35
+    public function offsetUnset($offset)
36
+    {
37 37
     unset($this->data[$offset]);
38
-  }
39
-  /**
40
-   * [offsetGet description]
41
-   * @date  2019-11-02
42
-   * @param [type]     $offset [description]
43
-   */
44
-  public function offsetGet($offset)
45
-  {
38
+    }
39
+    /**
40
+     * [offsetGet description]
41
+     * @date  2019-11-02
42
+     * @param [type]     $offset [description]
43
+     */
44
+    public function offsetGet($offset)
45
+    {
46 46
     return ($this->offsetExists($offset)) ? $this->data[$offset] : null;
47
-  }
48
-  /**
49
-   * [count description]
50
-   * @date   2019-11-02
51
-   * @return [type]     [description]
52
-   */
53
-  public function count()
54
-  {
47
+    }
48
+    /**
49
+     * [count description]
50
+     * @date   2019-11-02
51
+     * @return [type]     [description]
52
+     */
53
+    public function count()
54
+    {
55 55
     return count($this->_data);
56
-  }
56
+    }
57 57
 }
Please login to merge, or discard this patch.