@@ -135,16 +135,16 @@ discard block |
||
| 135 | 135 | public static function mergeRecursiveCustom( |
| 136 | 136 | $existing_row, |
| 137 | 137 | $conflict_row, |
| 138 | - callable $merge_resolver=null, |
|
| 139 | - $max_depth=null |
|
| 140 | - ){ |
|
| 138 | + callable $merge_resolver = null, |
|
| 139 | + $max_depth = null |
|
| 140 | + ) { |
|
| 141 | 141 | static::mustBeCountable($existing_row); |
| 142 | 142 | static::mustBeCountable($conflict_row); |
| 143 | 143 | |
| 144 | 144 | foreach ($conflict_row as $column => $conflict_value) { |
| 145 | 145 | |
| 146 | 146 | // not existing in first array |
| 147 | - if (!isset($existing_row[$column])) { |
|
| 147 | + if ( ! isset($existing_row[$column])) { |
|
| 148 | 148 | $existing_row[$column] = $conflict_value; |
| 149 | 149 | continue; |
| 150 | 150 | } |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | } |
| 178 | 178 | else { |
| 179 | 179 | // same resolution as array_merge_recursive |
| 180 | - if (!is_array($existing_value)) { |
|
| 180 | + if ( ! is_array($existing_value)) { |
|
| 181 | 181 | $existing_row[$column] = [$existing_value]; |
| 182 | 182 | } |
| 183 | 183 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | public static function mergePreservingDistincts( |
| 203 | 203 | $existing_row, |
| 204 | 204 | $conflict_row |
| 205 | - ){ |
|
| 205 | + ) { |
|
| 206 | 206 | return self::mergeInColumnBuckets($existing_row, $conflict_row); |
| 207 | 207 | } |
| 208 | 208 | |
@@ -219,8 +219,8 @@ discard block |
||
| 219 | 219 | public static function mergeInColumnBuckets( |
| 220 | 220 | $existing_row, |
| 221 | 221 | $conflict_row, |
| 222 | - $existing_key=null, |
|
| 223 | - $conflict_key=null |
|
| 222 | + $existing_key = null, |
|
| 223 | + $conflict_key = null |
|
| 224 | 224 | ) { |
| 225 | 225 | static::mustBeCountable($existing_row); |
| 226 | 226 | static::mustBeCountable($conflict_row); |
@@ -228,16 +228,16 @@ discard block |
||
| 228 | 228 | $merged_row = []; |
| 229 | 229 | foreach ($existing_row as $existing_column => $existing_value) { |
| 230 | 230 | if ($existing_value instanceof MergeBucket) { |
| 231 | - $merged_row[ $existing_column ] = $existing_value; |
|
| 231 | + $merged_row[$existing_column] = $existing_value; |
|
| 232 | 232 | } |
| 233 | 233 | else { |
| 234 | 234 | if (isset($existing_key)) { |
| 235 | - $merged_row[ $existing_column ] = MergeBucket::from([ |
|
| 235 | + $merged_row[$existing_column] = MergeBucket::from([ |
|
| 236 | 236 | $existing_key => $existing_value |
| 237 | 237 | ]); |
| 238 | 238 | } |
| 239 | 239 | else { |
| 240 | - $merged_row[ $existing_column ] = MergeBucket::from([ |
|
| 240 | + $merged_row[$existing_column] = MergeBucket::from([ |
|
| 241 | 241 | $existing_value |
| 242 | 242 | ]); |
| 243 | 243 | } |
@@ -245,26 +245,26 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | foreach ($conflict_row as $conflict_column => $conflict_value) { |
| 248 | - if (! isset($merged_row[ $conflict_column ])) { |
|
| 249 | - $merged_row[ $conflict_column ] = new MergeBucket; |
|
| 248 | + if ( ! isset($merged_row[$conflict_column])) { |
|
| 249 | + $merged_row[$conflict_column] = new MergeBucket; |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | if ($conflict_value instanceof MergeBucket) { |
| 253 | 253 | foreach ($conflict_value as $conflict_bucket_value) { |
| 254 | 254 | if (isset($conflict_key)) { |
| 255 | - $merged_row[ $conflict_column ][$conflict_key] = $conflict_bucket_value; |
|
| 255 | + $merged_row[$conflict_column][$conflict_key] = $conflict_bucket_value; |
|
| 256 | 256 | } |
| 257 | 257 | else { |
| 258 | - $merged_row[ $conflict_column ][] = $conflict_bucket_value; |
|
| 258 | + $merged_row[$conflict_column][] = $conflict_bucket_value; |
|
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | else { |
| 263 | 263 | if (isset($conflict_key)) { |
| 264 | - $merged_row[ $conflict_column ][$conflict_key] = $conflict_value; |
|
| 264 | + $merged_row[$conflict_column][$conflict_key] = $conflict_value; |
|
| 265 | 265 | } |
| 266 | 266 | else { |
| 267 | - $merged_row[ $conflict_column ][] = $conflict_value; |
|
| 267 | + $merged_row[$conflict_column][] = $conflict_value; |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | } |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | * @param array|Countable $row |
| 279 | 279 | * @param array $options : 'excluded_columns' |
| 280 | 280 | */ |
| 281 | - public static function cleanMergeDuplicates($row, array $options=[]) |
|
| 281 | + public static function cleanMergeDuplicates($row, array $options = []) |
|
| 282 | 282 | { |
| 283 | 283 | static::mustBeCountable($row); |
| 284 | 284 | |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | * @see mergePreservingDistincts() |
| 312 | 312 | * @see cleanMergeDuplicates() |
| 313 | 313 | */ |
| 314 | - public static function cleanMergeBuckets($row, array $options=[]) |
|
| 314 | + public static function cleanMergeBuckets($row, array $options = []) |
|
| 315 | 315 | { |
| 316 | 316 | static::mustBeCountable($row); |
| 317 | 317 | |
@@ -354,13 +354,13 @@ discard block |
||
| 354 | 354 | $id = serialize($value); |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - if (isset($ids[ $id ])) { |
|
| 358 | - unset($array[ $key ]); |
|
| 359 | - $ids[ $id ][] = $key; |
|
| 357 | + if (isset($ids[$id])) { |
|
| 358 | + unset($array[$key]); |
|
| 359 | + $ids[$id][] = $key; |
|
| 360 | 360 | continue; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - $ids[ $id ] = [$key]; |
|
| 363 | + $ids[$id] = [$key]; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | return $array; |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | } |
| 381 | 381 | else { |
| 382 | 382 | throw new \InvalidArgumentException( |
| 383 | - "keyExists() method missing on :\n". var_export($array, true) |
|
| 383 | + "keyExists() method missing on :\n".var_export($array, true) |
|
| 384 | 384 | ); |
| 385 | 385 | } |
| 386 | 386 | |
@@ -456,16 +456,16 @@ discard block |
||
| 456 | 456 | throw new \InvalidArgumentException( |
| 457 | 457 | "Different number of " |
| 458 | 458 | ." values and weights for weight mean calculation: \n" |
| 459 | - .var_export($values, true)."\n\n" |
|
| 459 | + .var_export($values, true)."\n\n" |
|
| 460 | 460 | .var_export($weights, true) |
| 461 | 461 | ); |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - if (!$values) |
|
| 464 | + if ( ! $values) |
|
| 465 | 465 | return null; |
| 466 | 466 | |
| 467 | - $weights_sum = array_sum($weights); |
|
| 468 | - if (!$weights_sum) |
|
| 467 | + $weights_sum = array_sum($weights); |
|
| 468 | + if ( ! $weights_sum) |
|
| 469 | 469 | return 0; |
| 470 | 470 | |
| 471 | 471 | $weighted_sum = 0; |
@@ -514,8 +514,8 @@ discard block |
||
| 514 | 514 | ); |
| 515 | 515 | |
| 516 | 516 | // The true location of the throw is still available through the backtrace |
| 517 | - $trace_location = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]; |
|
| 518 | - $reflectionClass = new \ReflectionClass( get_class($exception) ); |
|
| 517 | + $trace_location = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]; |
|
| 518 | + $reflectionClass = new \ReflectionClass(get_class($exception)); |
|
| 519 | 519 | |
| 520 | 520 | // file |
| 521 | 521 | if (isset($trace_location['file'])) { |
@@ -552,8 +552,8 @@ discard block |
||
| 552 | 552 | ); |
| 553 | 553 | |
| 554 | 554 | // The true location of the throw is still available through the backtrace |
| 555 | - $trace_location = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]; |
|
| 556 | - $reflectionClass = new \ReflectionClass( get_class($exception) ); |
|
| 555 | + $trace_location = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]; |
|
| 556 | + $reflectionClass = new \ReflectionClass(get_class($exception)); |
|
| 557 | 557 | |
| 558 | 558 | // file |
| 559 | 559 | if (isset($trace_location['file'])) { |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | * |
| 594 | 594 | * @return string The unique identifier of the group |
| 595 | 595 | */ |
| 596 | - public static function generateGroupId($row, array $groups_definitions, array $options=[]) |
|
| 596 | + public static function generateGroupId($row, array $groups_definitions, array $options = []) |
|
| 597 | 597 | { |
| 598 | 598 | Arrays::mustBeCountable($row); |
| 599 | 599 | |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | : ':' |
| 603 | 603 | ; |
| 604 | 604 | |
| 605 | - $groups_separator = ! empty($options['groups_separator']) |
|
| 605 | + $groups_separator = ! empty($options['groups_separator']) |
|
| 606 | 606 | ? $options['groups_separator'] |
| 607 | 607 | : '-' |
| 608 | 608 | ; |
@@ -616,32 +616,32 @@ discard block |
||
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | if (is_string($group_definition_value)) { |
| 619 | - if ( (is_array($row) && ! array_key_exists($group_definition_value, $row)) |
|
| 619 | + if ((is_array($row) && ! array_key_exists($group_definition_value, $row)) |
|
| 620 | 620 | || ($row instanceof \ArrayAcces && ! $row->offsetExists($group_definition_value)) |
| 621 | 621 | ) { |
| 622 | 622 | throw new UsageException( |
| 623 | 623 | 'Unset column for group id generation: ' |
| 624 | 624 | .var_export($group_definition_value, true) |
| 625 | - ."\n" . var_export($row, true) |
|
| 625 | + ."\n".var_export($row, true) |
|
| 626 | 626 | ); |
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | $part_name .= $group_definition_value; |
| 630 | - $group_result_value = $row[ $group_definition_value ]; |
|
| 630 | + $group_result_value = $row[$group_definition_value]; |
|
| 631 | 631 | } |
| 632 | 632 | elseif (is_int($group_definition_value)) { |
| 633 | - if ( (is_array($row) && ! array_key_exists($group_definition_value, $row)) |
|
| 633 | + if ((is_array($row) && ! array_key_exists($group_definition_value, $row)) |
|
| 634 | 634 | || ($row instanceof \ArrayAcces && ! $row->offsetExists($group_definition_value)) |
| 635 | 635 | ) { |
| 636 | 636 | throw new UsageException( |
| 637 | 637 | 'Unset column for group id generation: ' |
| 638 | 638 | .var_export($group_definition_value, true) |
| 639 | - ."\n" . var_export($row, true) |
|
| 639 | + ."\n".var_export($row, true) |
|
| 640 | 640 | ); |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | - $part_name .= $group_definition_value ? : '0'; |
|
| 644 | - $group_result_value = $row[ $group_definition_value ]; |
|
| 643 | + $part_name .= $group_definition_value ?: '0'; |
|
| 644 | + $group_result_value = $row[$group_definition_value]; |
|
| 645 | 645 | } |
| 646 | 646 | elseif (is_callable($group_definition_value)) { |
| 647 | 647 | |
@@ -665,12 +665,12 @@ discard block |
||
| 665 | 665 | throw new UsageException( |
| 666 | 666 | 'Bad value provided for group id generation: ' |
| 667 | 667 | .var_export($group_definition_value, true) |
| 668 | - ."\n" . var_export($row, true) |
|
| 668 | + ."\n".var_export($row, true) |
|
| 669 | 669 | ); |
| 670 | 670 | } |
| 671 | 671 | |
| 672 | - if (!is_null($part_name)) |
|
| 673 | - $group_parts[ $part_name ] = $group_result_value; |
|
| 672 | + if ( ! is_null($part_name)) |
|
| 673 | + $group_parts[$part_name] = $group_result_value; |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | // sort the groups by names (without it the same group could have multiple ids) |
@@ -682,13 +682,13 @@ discard block |
||
| 682 | 682 | if (is_object($group_value)) { |
| 683 | 683 | $group_value = get_class($group_value) |
| 684 | 684 | . '_' |
| 685 | - . hash( 'crc32b', var_export($group_value, true) ); |
|
| 685 | + . hash('crc32b', var_export($group_value, true)); |
|
| 686 | 686 | } |
| 687 | 687 | elseif (is_array($group_value)) { |
| 688 | - $group_value = 'array_' . hash( 'crc32b', var_export($group_value, true) ); |
|
| 688 | + $group_value = 'array_'.hash('crc32b', var_export($group_value, true)); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | - $out[] = $group_name . $key_value_separator . $group_value; |
|
| 691 | + $out[] = $group_name.$key_value_separator.$group_value; |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | return implode($groups_separator, $out); |