Completed
Push — master ( f45902...93f8ee )
by Jean
03:19
created
src/Arrays.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -134,16 +134,16 @@  discard block
 block discarded – undo
134 134
     public static function mergeRecursiveCustom(
135 135
         $existing_row,
136 136
         $conflict_row,
137
-        callable $merge_resolver=null,
138
-        $max_depth=null
139
-    ){
137
+        callable $merge_resolver = null,
138
+        $max_depth = null
139
+    ) {
140 140
         static::mustBeCountable($existing_row);
141 141
         static::mustBeCountable($conflict_row);
142 142
 
143 143
         foreach ($conflict_row as $column => $conflict_value) {
144 144
 
145 145
             // not existing in first array
146
-            if (!isset($existing_row[$column])) {
146
+            if ( ! isset($existing_row[$column])) {
147 147
                 $existing_row[$column] = $conflict_value;
148 148
                 continue;
149 149
             }
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
             }
177 177
             else {
178 178
                 // same resolution as array_merge_recursive
179
-                if (!is_array($existing_value)) {
179
+                if ( ! is_array($existing_value)) {
180 180
                     $existing_row[$column] = [$existing_value];
181 181
                 }
182 182
 
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
     public static function mergePreservingDistincts(
200 200
         $existing_row,
201 201
         $conflict_row
202
-    ){
202
+    ) {
203 203
         static::mustBeCountable($existing_row);
204 204
         static::mustBeCountable($conflict_row);
205 205
 
206 206
         $merge = static::mergeRecursiveCustom(
207 207
             $existing_row,
208 208
             $conflict_row,
209
-            function ($existing_value, $conflict_value, $column) {
209
+            function($existing_value, $conflict_value, $column) {
210 210
 
211 211
                 if ( ! $existing_value instanceof MergeBucket) {
212 212
                     $existing_value = MergeBucket::from()->push($existing_value);
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
      * @param  array|Countable   $row
236 236
      * @param  array             $options : 'excluded_columns'
237 237
      */
238
-    public static function cleanMergeDuplicates($row, array $options=[])
238
+    public static function cleanMergeDuplicates($row, array $options = [])
239 239
     {
240 240
         static::mustBeCountable($row);
241 241
 
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
      * @see mergePreservingDistincts()
269 269
      * @see cleanMergeDuplicates()
270 270
      */
271
-    public static function cleanMergeBuckets($row, array $options=[])
271
+    public static function cleanMergeBuckets($row, array $options = [])
272 272
     {
273 273
         static::mustBeCountable($row);
274 274
 
@@ -309,13 +309,13 @@  discard block
 block discarded – undo
309 309
                 $id = serialize($value);
310 310
             }
311 311
 
312
-            if (isset($ids[ $id ])) {
313
-                unset($array[ $key ]);
314
-                $ids[ $id ][] = $key;
312
+            if (isset($ids[$id])) {
313
+                unset($array[$key]);
314
+                $ids[$id][] = $key;
315 315
                 continue;
316 316
             }
317 317
 
318
-            $ids[ $id ] = [$key];
318
+            $ids[$id] = [$key];
319 319
         }
320 320
 
321 321
         return $array;
@@ -390,16 +390,16 @@  discard block
 block discarded – undo
390 390
             throw new \InvalidArgumentException(
391 391
                 "Different number of "
392 392
                 ." values and weights for weight mean calculation: \n"
393
-                .var_export($values,  true)."\n\n"
393
+                .var_export($values, true)."\n\n"
394 394
                 .var_export($weights, true)
395 395
             );
396 396
         }
397 397
 
398
-        if (!$values)
398
+        if ( ! $values)
399 399
             return null;
400 400
 
401
-        $weights_sum  = array_sum($weights);
402
-        if (!$weights_sum)
401
+        $weights_sum = array_sum($weights);
402
+        if ( ! $weights_sum)
403 403
             return 0;
404 404
 
405 405
         $weighted_sum = 0;
@@ -434,15 +434,15 @@  discard block
 block discarded – undo
434 434
      */
435 435
     public static function mustBeCountable($value)
436 436
     {
437
-        if ( ! static::isCountable($value) ) {
437
+        if ( ! static::isCountable($value)) {
438 438
             $exception = new \InvalidArgumentException(
439 439
                 "A value must be Countable instead of: \n"
440 440
                 .var_export($value, true)
441 441
             );
442 442
 
443 443
             // The true location of the throw is still available through the backtrace
444
-            $trace_location  = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0];
445
-            $reflectionClass = new \ReflectionClass( get_class($exception) );
444
+            $trace_location  = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0];
445
+            $reflectionClass = new \ReflectionClass(get_class($exception));
446 446
 
447 447
             // file
448 448
             if (isset($trace_location['file'])) {
Please login to merge, or discard this patch.
src/ChainableArray.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
     /**
29 29
      */
30
-    public static function from($data=[], $isConstant=false)
30
+    public static function from($data = [], $isConstant = false)
31 31
     {
32 32
         Arrays::mustBeCountable($data);
33 33
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
     /**
41 41
      */
42
-    public function __construct(array $data=[], $isConstant=false)
42
+    public function __construct(array $data = [], $isConstant = false)
43 43
     {
44 44
         $this->data       = $data;
45 45
         $this->isConstant = $isConstant;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      *
84 84
      * @return ChainableArray $this
85 85
      */
86
-    public function setConstant($state=true)
86
+    public function setConstant($state = true)
87 87
     {
88 88
         $this->isConstant = $state;
89 89
         return $this;
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
     /**
163 163
      * Checks if an argument is an array or a ChainableArray
164 164
      */
165
-    private function argumentIsArrayOrArrayObject( $argument )
165
+    private function argumentIsArrayOrArrayObject($argument)
166 166
     {
167 167
         return is_array($argument)
168 168
             || $argument instanceof ChainableArray;
@@ -177,15 +177,15 @@  discard block
 block discarded – undo
177 177
         $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 20);
178 178
         $i      = 1;
179 179
         $caller = $backtrace[$i];
180
-        while (     isset($backtrace[$i]['class'])
181
-                &&  $backtrace[$i]['class'] == __CLASS__ ) {
180
+        while (isset($backtrace[$i]['class'])
181
+                &&  $backtrace[$i]['class'] == __CLASS__) {
182 182
             $caller = $backtrace[$i];
183 183
             $i++;
184 184
         }
185 185
 
186 186
         $exception = new \ErrorException($message);
187 187
 
188
-        $reflectionClass = new \ReflectionClass( get_class($exception) );
188
+        $reflectionClass = new \ReflectionClass(get_class($exception));
189 189
 
190 190
         //file
191 191
         $reflectionProperty = $reflectionClass->getProperty('file');
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,8 +31,9 @@  discard block
 block discarded – undo
31 31
     {
32 32
         Arrays::mustBeCountable($data);
33 33
 
34
-        if ($data instanceof self)
35
-            return $data;
34
+        if ($data instanceof self) {
35
+                    return $data;
36
+        }
36 37
 
37 38
         return new static($data, $isConstant);
38 39
     }
@@ -101,8 +102,7 @@  discard block
 block discarded – undo
101 102
     {
102 103
         if ($this->isConstant) {
103 104
             return new static($out);
104
-        }
105
-        else {
105
+        } else {
106 106
             $this->data = $out;
107 107
             return $this;
108 108
         }
Please login to merge, or discard this patch.