@@ -64,14 +64,12 @@ discard block |
||
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 |
||
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 |
||
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]; |
@@ -245,15 +240,18 @@ discard block |
||
245 | 240 | public static function keepUniqueColumnValues(array $row, array $excluded_columns=[]) |
246 | 241 | { |
247 | 242 | foreach ($row as $column => &$values) { |
248 | - if (!is_array($values)) |
|
249 | - continue; |
|
243 | + if (!is_array($values)) { |
|
244 | + continue; |
|
245 | + } |
|
250 | 246 | |
251 | - if (in_array($column, $excluded_columns)) |
|
252 | - continue; |
|
247 | + if (in_array($column, $excluded_columns)) { |
|
248 | + continue; |
|
249 | + } |
|
253 | 250 | |
254 | 251 | $values = array_unique($values); |
255 | - if (count($values) == 1) |
|
256 | - $values = $values[0]; |
|
252 | + if (count($values) == 1) { |
|
253 | + $values = $values[0]; |
|
254 | + } |
|
257 | 255 | } |
258 | 256 | |
259 | 257 | return $row; |
@@ -280,8 +278,7 @@ discard block |
||
280 | 278 | foreach ($array as $key => $value) { |
281 | 279 | if (is_scalar($value)) { |
282 | 280 | $id = $value; |
283 | - } |
|
284 | - else { |
|
281 | + } else { |
|
285 | 282 | $id = serialize($value); |
286 | 283 | } |
287 | 284 | |
@@ -309,11 +306,13 @@ discard block |
||
309 | 306 | */ |
310 | 307 | public static function weightedMean($values, $weights) |
311 | 308 | { |
312 | - if ( ! is_array($values)) |
|
313 | - $values = [$values]; |
|
309 | + if ( ! is_array($values)) { |
|
310 | + $values = [$values]; |
|
311 | + } |
|
314 | 312 | |
315 | - if ( ! is_array($weights)) |
|
316 | - $weights = [$weights]; |
|
313 | + if ( ! is_array($weights)) { |
|
314 | + $weights = [$weights]; |
|
315 | + } |
|
317 | 316 | |
318 | 317 | if (count($values) != count($weights)) { |
319 | 318 | throw new \InvalidArgumentException( |
@@ -324,12 +323,14 @@ discard block |
||
324 | 323 | ); |
325 | 324 | } |
326 | 325 | |
327 | - if (!$values) |
|
328 | - return null; |
|
326 | + if (!$values) { |
|
327 | + return null; |
|
328 | + } |
|
329 | 329 | |
330 | 330 | $weights_sum = array_sum($weights); |
331 | - if (!$weights_sum) |
|
332 | - return 0; |
|
331 | + if (!$weights_sum) { |
|
332 | + return 0; |
|
333 | + } |
|
333 | 334 | |
334 | 335 | $weighted_sum = 0; |
335 | 336 | foreach ($values as $i => $value) { |