Completed
Push — master ( d20ccf...046303 )
by Jean
02:40
created
src/Arrays.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
     public static function mergeRecursiveCustom(
135 135
         array $existing_row,
136 136
         array $conflict_row,
137
-        callable $merge_resolver=null,
138
-        $max_depth=null
139
-    ){
137
+        callable $merge_resolver = null,
138
+        $max_depth = null
139
+    ) {
140 140
         foreach ($conflict_row as $column => $conflict_value) {
141 141
 
142 142
             // not existing in first array
143
-            if (!isset($existing_row[$column])) {
143
+            if ( ! isset($existing_row[$column])) {
144 144
                 $existing_row[$column] = $conflict_value;
145 145
                 continue;
146 146
             }
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
             }
174 174
             else {
175 175
                 // same resolution as array_merge_recursive
176
-                if (!is_array($existing_value)) {
176
+                if ( ! is_array($existing_value)) {
177 177
                     $existing_row[$column] = [$existing_value];
178 178
                 }
179 179
 
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
     public static function mergePreservingDistincts(
197 197
         array $existing_row,
198 198
         array $conflict_row
199
-    ){
199
+    ) {
200 200
         $merge = static::mergeRecursiveCustom(
201 201
             $existing_row,
202 202
             $conflict_row,
203
-            function ($existing_value, $conflict_value, $column) {
203
+            function($existing_value, $conflict_value, $column) {
204 204
 
205 205
                 if ( ! $existing_value instanceof MergeBucket) {
206 206
                     $existing_value = MergeBucket::from()->push($existing_value);
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
     {
231 231
         foreach ($merged_row as $entry => $values) {
232 232
             if ($values instanceof MergeBucket) {
233
-                $merged_row[ $entry ] = $values->toArray();
233
+                $merged_row[$entry] = $values->toArray();
234 234
             }
235 235
         }
236 236
 
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
      *
243 243
      * @see mergePreservingDistincts()
244 244
      */
245
-    public static function keepUniqueColumnValues(array $row, array $excluded_columns=[])
245
+    public static function keepUniqueColumnValues(array $row, array $excluded_columns = [])
246 246
     {
247 247
         foreach ($row as $column => &$values) {
248
-            if (!is_array($values))
248
+            if ( ! is_array($values))
249 249
                 continue;
250 250
 
251 251
             if (in_array($column, $excluded_columns))
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
      */
270 270
     public static function unique($array)
271 271
     {
272
-        if (! is_array($array) && ! $array instanceof \Traversable) {
272
+        if ( ! is_array($array) && ! $array instanceof \Traversable) {
273 273
             throw new \InvalidArgumentException(
274 274
                 "\$array must be an array or a \Traversable instead of: \n"
275 275
                 .var_export($array, true)
@@ -285,13 +285,13 @@  discard block
 block discarded – undo
285 285
                 $id = serialize($value);
286 286
             }
287 287
 
288
-            if (isset($ids[ $id ])) {
289
-                unset($array[ $key ]);
290
-                $ids[ $id ][] = $key;
288
+            if (isset($ids[$id])) {
289
+                unset($array[$key]);
290
+                $ids[$id][] = $key;
291 291
                 continue;
292 292
             }
293 293
 
294
-            $ids[ $id ] = [$key];
294
+            $ids[$id] = [$key];
295 295
         }
296 296
 
297 297
         return $array;
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
      */
309 309
     public static function sum($array)
310 310
     {
311
-        if (! is_array($array) && ! $array instanceof \Traversable) {
311
+        if ( ! is_array($array) && ! $array instanceof \Traversable) {
312 312
             throw new \InvalidArgumentException(
313 313
                 "\$array must be an array or a \Traversable instead of: \n"
314 314
                 .var_export($array, true)
@@ -384,16 +384,16 @@  discard block
 block discarded – undo
384 384
             throw new \InvalidArgumentException(
385 385
                 "Different number of "
386 386
                 ." values and weights for weight mean calculation: \n"
387
-                .var_export($values,  true)."\n\n"
387
+                .var_export($values, true)."\n\n"
388 388
                 .var_export($weights, true)
389 389
             );
390 390
         }
391 391
 
392
-        if (!$values)
392
+        if ( ! $values)
393 393
             return null;
394 394
 
395
-        $weights_sum  = array_sum($weights);
396
-        if (!$weights_sum)
395
+        $weights_sum = array_sum($weights);
396
+        if ( ! $weights_sum)
397 397
             return 0;
398 398
 
399 399
         $weighted_sum = 0;
Please login to merge, or discard this patch.