@@ -134,13 +134,13 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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); |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * @param array|Traversable $row |
| 230 | 230 | * @param array $options : 'excluded_columns' |
| 231 | 231 | */ |
| 232 | - public static function cleanMergeDuplicates($row, array $options=[]) |
|
| 232 | + public static function cleanMergeDuplicates($row, array $options = []) |
|
| 233 | 233 | { |
| 234 | 234 | if ( ! is_array($row) && ! $row instanceof \Traversable) { |
| 235 | 235 | throw new \InvalidArgumentException( |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | * |
| 267 | 267 | * @see mergePreservingDistincts() |
| 268 | 268 | */ |
| 269 | - public static function cleanMergeBuckets($row, array $options=[]) |
|
| 269 | + public static function cleanMergeBuckets($row, array $options = []) |
|
| 270 | 270 | { |
| 271 | 271 | if ( ! is_array($row) && ! $row instanceof \Traversable) { |
| 272 | 272 | throw new \InvalidArgumentException( |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | */ |
| 302 | 302 | public static function unique($array) |
| 303 | 303 | { |
| 304 | - if (! is_array($array) && ! $array instanceof \Traversable) { |
|
| 304 | + if ( ! is_array($array) && ! $array instanceof \Traversable) { |
|
| 305 | 305 | throw new \InvalidArgumentException( |
| 306 | 306 | "\$array must be an array or a \Traversable instead of: \n" |
| 307 | 307 | .var_export($array, true) |
@@ -317,13 +317,13 @@ discard block |
||
| 317 | 317 | $id = serialize($value); |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - if (isset($ids[ $id ])) { |
|
| 321 | - unset($array[ $key ]); |
|
| 322 | - $ids[ $id ][] = $key; |
|
| 320 | + if (isset($ids[$id])) { |
|
| 321 | + unset($array[$key]); |
|
| 322 | + $ids[$id][] = $key; |
|
| 323 | 323 | continue; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - $ids[ $id ] = [$key]; |
|
| 326 | + $ids[$id] = [$key]; |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | return $array; |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | */ |
| 341 | 341 | public static function sum($array) |
| 342 | 342 | { |
| 343 | - if (! is_array($array) && ! $array instanceof \Traversable) { |
|
| 343 | + if ( ! is_array($array) && ! $array instanceof \Traversable) { |
|
| 344 | 344 | throw new \InvalidArgumentException( |
| 345 | 345 | "\$array must be an array or a \Traversable instead of: \n" |
| 346 | 346 | .var_export($array, true) |
@@ -403,16 +403,16 @@ discard block |
||
| 403 | 403 | throw new \InvalidArgumentException( |
| 404 | 404 | "Different number of " |
| 405 | 405 | ." values and weights for weight mean calculation: \n" |
| 406 | - .var_export($values, true)."\n\n" |
|
| 406 | + .var_export($values, true)."\n\n" |
|
| 407 | 407 | .var_export($weights, true) |
| 408 | 408 | ); |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - if (!$values) |
|
| 411 | + if ( ! $values) |
|
| 412 | 412 | return null; |
| 413 | 413 | |
| 414 | - $weights_sum = array_sum($weights); |
|
| 415 | - if (!$weights_sum) |
|
| 414 | + $weights_sum = array_sum($weights); |
|
| 415 | + if ( ! $weights_sum) |
|
| 416 | 416 | return 0; |
| 417 | 417 | |
| 418 | 418 | $weighted_sum = 0; |