Completed
Push — master ( 7732b1...2a9c77 )
by Jean
02:09
created
src/Arrays.php 1 patch
Braces   +42 added lines, -40 removed lines patch added patch discarded remove patch
@@ -64,14 +64,12 @@  discard block
 block discarded – undo
64 64
                 )
65 65
                 {
66 66
                     $array1[$key] = self::merge($array1[$key], $value);
67
-                }
68
-                else
67
+                } else
69 68
                 {
70 69
                     $array1[$key] = $value;
71 70
                 }
72 71
             }
73
-        }
74
-        else
72
+        } else
75 73
         {
76 74
             foreach ($array2 as $value)
77 75
             {
@@ -96,14 +94,12 @@  discard block
 block discarded – undo
96 94
                         )
97 95
                         {
98 96
                             $array1[$key] = self::merge($array1[$key], $value);
99
-                        }
100
-                        else
97
+                        } else
101 98
                         {
102 99
                             $array1[$key] = $value;
103 100
                         }
104 101
                     }
105
-                }
106
-                else
102
+                } else
107 103
                 {
108 104
                     foreach ($array2 as $value)
109 105
                     {
@@ -170,8 +166,7 @@  discard block
 block discarded – undo
170 166
                         $column,
171 167
                     ]
172 168
                 );
173
-            }
174
-            else {
169
+            } else {
175 170
                 // same resolution as array_merge_recursive
176 171
                 if (!is_array($existing_value)) {
177 172
                     $existing_row[$column] = [$existing_value];
@@ -244,15 +239,18 @@  discard block
 block discarded – undo
244 239
                           ;
245 240
 
246 241
         foreach ($row as $column => &$values) {
247
-            if ( ! $values instanceof MergeBucket)
248
-                continue;
242
+            if ( ! $values instanceof MergeBucket) {
243
+                            continue;
244
+            }
249 245
 
250
-            if (in_array($column, $excluded_columns))
251
-                continue;
246
+            if (in_array($column, $excluded_columns)) {
247
+                            continue;
248
+            }
252 249
 
253 250
             $values = Arrays::unique($values);
254
-            if (count($values) == 1)
255
-                $values = $values[0];
251
+            if (count($values) == 1) {
252
+                            $values = $values[0];
253
+            }
256 254
         }
257 255
 
258 256
         return $row;
@@ -281,11 +279,13 @@  discard block
 block discarded – undo
281 279
                           ;
282 280
 
283 281
         foreach ($row as $column => &$values) {
284
-            if (in_array($column, $excluded_columns))
285
-                continue;
282
+            if (in_array($column, $excluded_columns)) {
283
+                            continue;
284
+            }
286 285
 
287
-            if ($values instanceof MergeBucket)
288
-                $values = $values->toArray();
286
+            if ($values instanceof MergeBucket) {
287
+                            $values = $values->toArray();
288
+            }
289 289
         }
290 290
 
291 291
         return $row;
@@ -312,8 +312,7 @@  discard block
 block discarded – undo
312 312
         foreach ($array as $key => $value) {
313 313
             if (is_scalar($value)) {
314 314
                 $id = $value;
315
-            }
316
-            else {
315
+            } else {
317 316
                 $id = serialize($value);
318 317
             }
319 318
 
@@ -351,16 +350,13 @@  discard block
 block discarded – undo
351 350
         foreach ($array as $key => &$value) { // &for optimization
352 351
             if (is_scalar($value)) {
353 352
                 $sum += $value;
354
-            }
355
-            elseif (is_null($value)) {
353
+            } elseif (is_null($value)) {
356 354
                 continue;
357
-            }
358
-            elseif (is_array($value)) {
355
+            } elseif (is_array($value)) {
359 356
                 throw new \InvalidArgumentException(
360 357
                     "Trying to sum an array with '$sum': ".var_export($value, true)
361 358
                 );
362
-            }
363
-            elseif (is_object($value)) {
359
+            } elseif (is_object($value)) {
364 360
                 if ( ! method_exists($value, 'toNumber')) {
365 361
                     throw new \InvalidArgumentEXception(
366 362
                          "Trying to sum a ".get_class($value)." object which cannot be casted as a number. "
@@ -387,17 +383,21 @@  discard block
 block discarded – undo
387 383
      */
388 384
     public static function weightedMean($values, $weights)
389 385
     {
390
-        if ($values instanceof ChainableArray)
391
-            $values = $values->toArray();
386
+        if ($values instanceof ChainableArray) {
387
+                    $values = $values->toArray();
388
+        }
392 389
 
393
-        if ($weights instanceof ChainableArray)
394
-            $weights = $weights->toArray();
390
+        if ($weights instanceof ChainableArray) {
391
+                    $weights = $weights->toArray();
392
+        }
395 393
 
396
-        if ( ! is_array($values))
397
-            $values = [$values];
394
+        if ( ! is_array($values)) {
395
+                    $values = [$values];
396
+        }
398 397
 
399
-        if ( ! is_array($weights))
400
-            $weights = [$weights];
398
+        if ( ! is_array($weights)) {
399
+                    $weights = [$weights];
400
+        }
401 401
 
402 402
         if (count($values) != count($weights)) {
403 403
             throw new \InvalidArgumentException(
@@ -408,12 +408,14 @@  discard block
 block discarded – undo
408 408
             );
409 409
         }
410 410
 
411
-        if (!$values)
412
-            return null;
411
+        if (!$values) {
412
+                    return null;
413
+        }
413 414
 
414 415
         $weights_sum  = array_sum($weights);
415
-        if (!$weights_sum)
416
-            return 0;
416
+        if (!$weights_sum) {
417
+                    return 0;
418
+        }
417 419
 
418 420
         $weighted_sum = 0;
419 421
         foreach ($values as $i => $value) {
Please login to merge, or discard this patch.