@@ -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,21 +245,21 @@ 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 | - $merged_row[ $existing_column ] = $conflict_bucket_value; |
|
| 254 | + $merged_row[$existing_column] = $conflict_bucket_value; |
|
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | 257 | else { |
| 258 | 258 | if (isset($conflict_key)) { |
| 259 | - $merged_row[ $conflict_column ][$conflict_key] = $conflict_value; |
|
| 259 | + $merged_row[$conflict_column][$conflict_key] = $conflict_value; |
|
| 260 | 260 | } |
| 261 | 261 | else { |
| 262 | - $merged_row[ $conflict_column ][] = $conflict_value; |
|
| 262 | + $merged_row[$conflict_column][] = $conflict_value; |
|
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | } |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | * @param array|Countable $row |
| 274 | 274 | * @param array $options : 'excluded_columns' |
| 275 | 275 | */ |
| 276 | - public static function cleanMergeDuplicates($row, array $options=[]) |
|
| 276 | + public static function cleanMergeDuplicates($row, array $options = []) |
|
| 277 | 277 | { |
| 278 | 278 | static::mustBeCountable($row); |
| 279 | 279 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | * @see mergePreservingDistincts() |
| 307 | 307 | * @see cleanMergeDuplicates() |
| 308 | 308 | */ |
| 309 | - public static function cleanMergeBuckets($row, array $options=[]) |
|
| 309 | + public static function cleanMergeBuckets($row, array $options = []) |
|
| 310 | 310 | { |
| 311 | 311 | static::mustBeCountable($row); |
| 312 | 312 | |
@@ -349,13 +349,13 @@ discard block |
||
| 349 | 349 | $id = serialize($value); |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - if (isset($ids[ $id ])) { |
|
| 353 | - unset($array[ $key ]); |
|
| 354 | - $ids[ $id ][] = $key; |
|
| 352 | + if (isset($ids[$id])) { |
|
| 353 | + unset($array[$key]); |
|
| 354 | + $ids[$id][] = $key; |
|
| 355 | 355 | continue; |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - $ids[ $id ] = [$key]; |
|
| 358 | + $ids[$id] = [$key]; |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | return $array; |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | } |
| 376 | 376 | else { |
| 377 | 377 | throw new \InvalidArgumentException( |
| 378 | - "keyExists() method missing on :\n". var_export($array, true) |
|
| 378 | + "keyExists() method missing on :\n".var_export($array, true) |
|
| 379 | 379 | ); |
| 380 | 380 | } |
| 381 | 381 | |
@@ -451,16 +451,16 @@ discard block |
||
| 451 | 451 | throw new \InvalidArgumentException( |
| 452 | 452 | "Different number of " |
| 453 | 453 | ." values and weights for weight mean calculation: \n" |
| 454 | - .var_export($values, true)."\n\n" |
|
| 454 | + .var_export($values, true)."\n\n" |
|
| 455 | 455 | .var_export($weights, true) |
| 456 | 456 | ); |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | - if (!$values) |
|
| 459 | + if ( ! $values) |
|
| 460 | 460 | return null; |
| 461 | 461 | |
| 462 | - $weights_sum = array_sum($weights); |
|
| 463 | - if (!$weights_sum) |
|
| 462 | + $weights_sum = array_sum($weights); |
|
| 463 | + if ( ! $weights_sum) |
|
| 464 | 464 | return 0; |
| 465 | 465 | |
| 466 | 466 | $weighted_sum = 0; |
@@ -509,8 +509,8 @@ discard block |
||
| 509 | 509 | ); |
| 510 | 510 | |
| 511 | 511 | // The true location of the throw is still available through the backtrace |
| 512 | - $trace_location = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]; |
|
| 513 | - $reflectionClass = new \ReflectionClass( get_class($exception) ); |
|
| 512 | + $trace_location = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]; |
|
| 513 | + $reflectionClass = new \ReflectionClass(get_class($exception)); |
|
| 514 | 514 | |
| 515 | 515 | // file |
| 516 | 516 | if (isset($trace_location['file'])) { |
@@ -547,8 +547,8 @@ discard block |
||
| 547 | 547 | ); |
| 548 | 548 | |
| 549 | 549 | // The true location of the throw is still available through the backtrace |
| 550 | - $trace_location = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]; |
|
| 551 | - $reflectionClass = new \ReflectionClass( get_class($exception) ); |
|
| 550 | + $trace_location = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]; |
|
| 551 | + $reflectionClass = new \ReflectionClass(get_class($exception)); |
|
| 552 | 552 | |
| 553 | 553 | // file |
| 554 | 554 | if (isset($trace_location['file'])) { |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | * |
| 589 | 589 | * @return string The unique identifier of the group |
| 590 | 590 | */ |
| 591 | - public static function generateGroupId($row, array $groups_definitions, array $options=[]) |
|
| 591 | + public static function generateGroupId($row, array $groups_definitions, array $options = []) |
|
| 592 | 592 | { |
| 593 | 593 | Arrays::mustBeCountable($row); |
| 594 | 594 | |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | : ':' |
| 598 | 598 | ; |
| 599 | 599 | |
| 600 | - $groups_separator = ! empty($options['groups_separator']) |
|
| 600 | + $groups_separator = ! empty($options['groups_separator']) |
|
| 601 | 601 | ? $options['groups_separator'] |
| 602 | 602 | : '-' |
| 603 | 603 | ; |
@@ -611,32 +611,32 @@ discard block |
||
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | if (is_string($group_definition_value)) { |
| 614 | - if ( (is_array($row) && ! array_key_exists($group_definition_value, $row)) |
|
| 614 | + if ((is_array($row) && ! array_key_exists($group_definition_value, $row)) |
|
| 615 | 615 | || ($row instanceof \ArrayAcces && ! $row->offsetExists($group_definition_value)) |
| 616 | 616 | ) { |
| 617 | 617 | throw new UsageException( |
| 618 | 618 | 'Unset column for group id generation: ' |
| 619 | 619 | .var_export($group_definition_value, true) |
| 620 | - ."\n" . var_export($row, true) |
|
| 620 | + ."\n".var_export($row, true) |
|
| 621 | 621 | ); |
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | $part_name .= $group_definition_value; |
| 625 | - $group_result_value = $row[ $group_definition_value ]; |
|
| 625 | + $group_result_value = $row[$group_definition_value]; |
|
| 626 | 626 | } |
| 627 | 627 | elseif (is_int($group_definition_value)) { |
| 628 | - if ( (is_array($row) && ! array_key_exists($group_definition_value, $row)) |
|
| 628 | + if ((is_array($row) && ! array_key_exists($group_definition_value, $row)) |
|
| 629 | 629 | || ($row instanceof \ArrayAcces && ! $row->offsetExists($group_definition_value)) |
| 630 | 630 | ) { |
| 631 | 631 | throw new UsageException( |
| 632 | 632 | 'Unset column for group id generation: ' |
| 633 | 633 | .var_export($group_definition_value, true) |
| 634 | - ."\n" . var_export($row, true) |
|
| 634 | + ."\n".var_export($row, true) |
|
| 635 | 635 | ); |
| 636 | 636 | } |
| 637 | 637 | |
| 638 | - $part_name .= $group_definition_value ? : '0'; |
|
| 639 | - $group_result_value = $row[ $group_definition_value ]; |
|
| 638 | + $part_name .= $group_definition_value ?: '0'; |
|
| 639 | + $group_result_value = $row[$group_definition_value]; |
|
| 640 | 640 | } |
| 641 | 641 | elseif (is_callable($group_definition_value)) { |
| 642 | 642 | |
@@ -660,12 +660,12 @@ discard block |
||
| 660 | 660 | throw new UsageException( |
| 661 | 661 | 'Bad value provided for group id generation: ' |
| 662 | 662 | .var_export($group_definition_value, true) |
| 663 | - ."\n" . var_export($row, true) |
|
| 663 | + ."\n".var_export($row, true) |
|
| 664 | 664 | ); |
| 665 | 665 | } |
| 666 | 666 | |
| 667 | - if (!is_null($part_name)) |
|
| 668 | - $group_parts[ $part_name ] = $group_result_value; |
|
| 667 | + if ( ! is_null($part_name)) |
|
| 668 | + $group_parts[$part_name] = $group_result_value; |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | // sort the groups by names (without it the same group could have multiple ids) |
@@ -677,13 +677,13 @@ discard block |
||
| 677 | 677 | if (is_object($group_value)) { |
| 678 | 678 | $group_value = get_class($group_value) |
| 679 | 679 | . '_' |
| 680 | - . hash( 'crc32b', var_export($group_value, true) ); |
|
| 680 | + . hash('crc32b', var_export($group_value, true)); |
|
| 681 | 681 | } |
| 682 | 682 | elseif (is_array($group_value)) { |
| 683 | - $group_value = 'array_' . hash( 'crc32b', var_export($group_value, true) ); |
|
| 683 | + $group_value = 'array_'.hash('crc32b', var_export($group_value, true)); |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | - $out[] = $group_name . $key_value_separator . $group_value; |
|
| 686 | + $out[] = $group_name.$key_value_separator.$group_value; |
|
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | return implode($groups_separator, $out); |