@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $excluded_columns = isset($options['excluded_columns']) |
281 | 281 | ? $options['excluded_columns'] |
282 | 282 | : [] |
283 | - ; |
|
283 | + ; |
|
284 | 284 | |
285 | 285 | foreach ($row as $column => &$values) { |
286 | 286 | if ( ! $values instanceof MergeBucket) |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | $excluded_columns = isset($options['excluded_columns']) |
314 | 314 | ? $options['excluded_columns'] |
315 | 315 | : [] |
316 | - ; |
|
316 | + ; |
|
317 | 317 | |
318 | 318 | foreach ($row as $column => &$values) { |
319 | 319 | if (in_array($column, $excluded_columns)) { |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | elseif (is_object($value)) { |
412 | 412 | if ( ! method_exists($value, 'toNumber')) { |
413 | 413 | throw new \InvalidArgumentEXception( |
414 | - "Trying to sum a ".get_class($value)." object which cannot be casted as a number. " |
|
414 | + "Trying to sum a ".get_class($value)." object which cannot be casted as a number. " |
|
415 | 415 | ."Please add a toNumber() method." |
416 | 416 | ); |
417 | 417 | } |
@@ -595,12 +595,12 @@ discard block |
||
595 | 595 | $key_value_separator = ! empty($options['key_value_separator']) |
596 | 596 | ? $options['key_value_separator'] |
597 | 597 | : ':' |
598 | - ; |
|
598 | + ; |
|
599 | 599 | |
600 | 600 | $groups_separator = ! empty($options['groups_separator']) |
601 | 601 | ? $options['groups_separator'] |
602 | 602 | : '-' |
603 | - ; |
|
603 | + ; |
|
604 | 604 | |
605 | 605 | $group_parts = []; |
606 | 606 | foreach ($groups_definitions as $group_definition_key => $group_definition_value) { |
@@ -676,8 +676,8 @@ discard block |
||
676 | 676 | foreach ($group_parts as $group_name => $group_value) { |
677 | 677 | if (is_object($group_value)) { |
678 | 678 | $group_value = get_class($group_value) |
679 | - . '_' |
|
680 | - . hash( 'crc32b', var_export($group_value, true) ); |
|
679 | + . '_' |
|
680 | + . hash( 'crc32b', var_export($group_value, true) ); |
|
681 | 681 | } |
682 | 682 | elseif (is_array($group_value)) { |
683 | 683 | $group_value = 'array_' . hash( 'crc32b', var_export($group_value, true) ); |
@@ -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); |
@@ -65,14 +65,12 @@ discard block |
||
65 | 65 | ) |
66 | 66 | { |
67 | 67 | $array1[$key] = self::merge($array1[$key], $value); |
68 | - } |
|
69 | - else |
|
68 | + } else |
|
70 | 69 | { |
71 | 70 | $array1[$key] = $value; |
72 | 71 | } |
73 | 72 | } |
74 | - } |
|
75 | - else |
|
73 | + } else |
|
76 | 74 | { |
77 | 75 | foreach ($array2 as $value) |
78 | 76 | { |
@@ -97,14 +95,12 @@ discard block |
||
97 | 95 | ) |
98 | 96 | { |
99 | 97 | $array1[$key] = self::merge($array1[$key], $value); |
100 | - } |
|
101 | - else |
|
98 | + } else |
|
102 | 99 | { |
103 | 100 | $array1[$key] = $value; |
104 | 101 | } |
105 | 102 | } |
106 | - } |
|
107 | - else |
|
103 | + } else |
|
108 | 104 | { |
109 | 105 | foreach ($array2 as $value) |
110 | 106 | { |
@@ -174,8 +170,7 @@ discard block |
||
174 | 170 | $column, |
175 | 171 | ] |
176 | 172 | ); |
177 | - } |
|
178 | - else { |
|
173 | + } else { |
|
179 | 174 | // same resolution as array_merge_recursive |
180 | 175 | if (!is_array($existing_value)) { |
181 | 176 | $existing_row[$column] = [$existing_value]; |
@@ -229,14 +224,12 @@ discard block |
||
229 | 224 | foreach ($existing_row as $existing_column => $existing_value) { |
230 | 225 | if ($existing_value instanceof MergeBucket) { |
231 | 226 | $merged_row[ $existing_column ] = $existing_value; |
232 | - } |
|
233 | - else { |
|
227 | + } else { |
|
234 | 228 | if (isset($existing_key)) { |
235 | 229 | $merged_row[ $existing_column ] = MergeBucket::from([ |
236 | 230 | $existing_key => $existing_value |
237 | 231 | ]); |
238 | - } |
|
239 | - else { |
|
232 | + } else { |
|
240 | 233 | $merged_row[ $existing_column ] = MergeBucket::from([ |
241 | 234 | $existing_value |
242 | 235 | ]); |
@@ -253,12 +246,10 @@ discard block |
||
253 | 246 | foreach ($conflict_value as $conflict_bucket_value) { |
254 | 247 | $merged_row[ $existing_column ] = $conflict_bucket_value; |
255 | 248 | } |
256 | - } |
|
257 | - else { |
|
249 | + } else { |
|
258 | 250 | if (isset($conflict_key)) { |
259 | 251 | $merged_row[ $conflict_column ][$conflict_key] = $conflict_value; |
260 | - } |
|
261 | - else { |
|
252 | + } else { |
|
262 | 253 | $merged_row[ $conflict_column ][] = $conflict_value; |
263 | 254 | } |
264 | 255 | } |
@@ -283,15 +274,18 @@ discard block |
||
283 | 274 | ; |
284 | 275 | |
285 | 276 | foreach ($row as $column => &$values) { |
286 | - if ( ! $values instanceof MergeBucket) |
|
287 | - continue; |
|
277 | + if ( ! $values instanceof MergeBucket) { |
|
278 | + continue; |
|
279 | + } |
|
288 | 280 | |
289 | - if (in_array($column, $excluded_columns)) |
|
290 | - continue; |
|
281 | + if (in_array($column, $excluded_columns)) { |
|
282 | + continue; |
|
283 | + } |
|
291 | 284 | |
292 | 285 | $values = Arrays::unique($values); |
293 | - if (count($values) == 1) |
|
294 | - $values = $values[0]; |
|
286 | + if (count($values) == 1) { |
|
287 | + $values = $values[0]; |
|
288 | + } |
|
295 | 289 | } |
296 | 290 | |
297 | 291 | return $row; |
@@ -344,8 +338,7 @@ discard block |
||
344 | 338 | foreach ($array as $key => $value) { |
345 | 339 | if (is_scalar($value)) { |
346 | 340 | $id = $value; |
347 | - } |
|
348 | - else { |
|
341 | + } else { |
|
349 | 342 | $id = serialize($value); |
350 | 343 | } |
351 | 344 | |
@@ -369,11 +362,9 @@ discard block |
||
369 | 362 | |
370 | 363 | if (is_array($array)) { |
371 | 364 | return array_key_exists($key, $array); |
372 | - } |
|
373 | - elseif ($array instanceof ChainableArray || method_exists($array, 'keyExists')) { |
|
365 | + } elseif ($array instanceof ChainableArray || method_exists($array, 'keyExists')) { |
|
374 | 366 | return $array->keyExists($key); |
375 | - } |
|
376 | - else { |
|
367 | + } else { |
|
377 | 368 | throw new \InvalidArgumentException( |
378 | 369 | "keyExists() method missing on :\n". var_export($array, true) |
379 | 370 | ); |
@@ -399,16 +390,13 @@ discard block |
||
399 | 390 | foreach ($array as $key => &$value) { // &for optimization |
400 | 391 | if (is_scalar($value)) { |
401 | 392 | $sum += $value; |
402 | - } |
|
403 | - elseif (is_null($value)) { |
|
393 | + } elseif (is_null($value)) { |
|
404 | 394 | continue; |
405 | - } |
|
406 | - elseif (is_array($value)) { |
|
395 | + } elseif (is_array($value)) { |
|
407 | 396 | throw new \InvalidArgumentException( |
408 | 397 | "Trying to sum an array with '$sum': ".var_export($value, true) |
409 | 398 | ); |
410 | - } |
|
411 | - elseif (is_object($value)) { |
|
399 | + } elseif (is_object($value)) { |
|
412 | 400 | if ( ! method_exists($value, 'toNumber')) { |
413 | 401 | throw new \InvalidArgumentEXception( |
414 | 402 | "Trying to sum a ".get_class($value)." object which cannot be casted as a number. " |
@@ -435,17 +423,21 @@ discard block |
||
435 | 423 | */ |
436 | 424 | public static function weightedMean($values, $weights) |
437 | 425 | { |
438 | - if ($values instanceof ChainableArray) |
|
439 | - $values = $values->toArray(); |
|
426 | + if ($values instanceof ChainableArray) { |
|
427 | + $values = $values->toArray(); |
|
428 | + } |
|
440 | 429 | |
441 | - if ($weights instanceof ChainableArray) |
|
442 | - $weights = $weights->toArray(); |
|
430 | + if ($weights instanceof ChainableArray) { |
|
431 | + $weights = $weights->toArray(); |
|
432 | + } |
|
443 | 433 | |
444 | - if ( ! is_array($values)) |
|
445 | - $values = [$values]; |
|
434 | + if ( ! is_array($values)) { |
|
435 | + $values = [$values]; |
|
436 | + } |
|
446 | 437 | |
447 | - if ( ! is_array($weights)) |
|
448 | - $weights = [$weights]; |
|
438 | + if ( ! is_array($weights)) { |
|
439 | + $weights = [$weights]; |
|
440 | + } |
|
449 | 441 | |
450 | 442 | if (count($values) != count($weights)) { |
451 | 443 | throw new \InvalidArgumentException( |
@@ -456,12 +448,14 @@ discard block |
||
456 | 448 | ); |
457 | 449 | } |
458 | 450 | |
459 | - if (!$values) |
|
460 | - return null; |
|
451 | + if (!$values) { |
|
452 | + return null; |
|
453 | + } |
|
461 | 454 | |
462 | 455 | $weights_sum = array_sum($weights); |
463 | - if (!$weights_sum) |
|
464 | - return 0; |
|
456 | + if (!$weights_sum) { |
|
457 | + return 0; |
|
458 | + } |
|
465 | 459 | |
466 | 460 | $weighted_sum = 0; |
467 | 461 | foreach ($values as $i => $value) { |
@@ -500,8 +494,9 @@ discard block |
||
500 | 494 | */ |
501 | 495 | public static function mustBeCountable($value) |
502 | 496 | { |
503 | - if (static::isCountable($value)) |
|
504 | - return true; |
|
497 | + if (static::isCountable($value)) { |
|
498 | + return true; |
|
499 | + } |
|
505 | 500 | |
506 | 501 | $exception = new \InvalidArgumentException( |
507 | 502 | "A value must be Countable instead of: \n" |
@@ -538,8 +533,9 @@ discard block |
||
538 | 533 | */ |
539 | 534 | public static function mustBeTraversable($value) |
540 | 535 | { |
541 | - if (static::isTraversable($value)) |
|
542 | - return true; |
|
536 | + if (static::isTraversable($value)) { |
|
537 | + return true; |
|
538 | + } |
|
543 | 539 | |
544 | 540 | $exception = new \InvalidArgumentException( |
545 | 541 | "A value must be Traversable instead of: \n" |
@@ -623,8 +619,7 @@ discard block |
||
623 | 619 | |
624 | 620 | $part_name .= $group_definition_value; |
625 | 621 | $group_result_value = $row[ $group_definition_value ]; |
626 | - } |
|
627 | - elseif (is_int($group_definition_value)) { |
|
622 | + } elseif (is_int($group_definition_value)) { |
|
628 | 623 | if ( (is_array($row) && ! array_key_exists($group_definition_value, $row)) |
629 | 624 | || ($row instanceof \ArrayAcces && ! $row->offsetExists($group_definition_value)) |
630 | 625 | ) { |
@@ -637,8 +632,7 @@ discard block |
||
637 | 632 | |
638 | 633 | $part_name .= $group_definition_value ? : '0'; |
639 | 634 | $group_result_value = $row[ $group_definition_value ]; |
640 | - } |
|
641 | - elseif (is_callable($group_definition_value)) { |
|
635 | + } elseif (is_callable($group_definition_value)) { |
|
642 | 636 | |
643 | 637 | if (is_string($group_definition_value)) { |
644 | 638 | $part_name .= $group_definition_value; |
@@ -647,16 +641,14 @@ discard block |
||
647 | 641 | elseif (is_object($group_definition_value) && ($group_definition_value instanceof \Closure)) { |
648 | 642 | $part_name .= 'unnamed-closure-' |
649 | 643 | . hash('crc32b', var_export($group_definition_value, true)); |
650 | - } |
|
651 | - elseif (is_array($group_definition_value)) { |
|
644 | + } elseif (is_array($group_definition_value)) { |
|
652 | 645 | $part_name .= implode('::', $group_definition_value); |
653 | 646 | } |
654 | 647 | |
655 | 648 | $group_result_value = call_user_func_array($group_definition_value, [ |
656 | 649 | $row, &$part_name |
657 | 650 | ]); |
658 | - } |
|
659 | - else { |
|
651 | + } else { |
|
660 | 652 | throw new UsageException( |
661 | 653 | 'Bad value provided for group id generation: ' |
662 | 654 | .var_export($group_definition_value, true) |
@@ -664,8 +656,9 @@ discard block |
||
664 | 656 | ); |
665 | 657 | } |
666 | 658 | |
667 | - if (!is_null($part_name)) |
|
668 | - $group_parts[ $part_name ] = $group_result_value; |
|
659 | + if (!is_null($part_name)) { |
|
660 | + $group_parts[ $part_name ] = $group_result_value; |
|
661 | + } |
|
669 | 662 | } |
670 | 663 | |
671 | 664 | // sort the groups by names (without it the same group could have multiple ids) |
@@ -678,8 +671,7 @@ discard block |
||
678 | 671 | $group_value = get_class($group_value) |
679 | 672 | . '_' |
680 | 673 | . hash( 'crc32b', var_export($group_value, true) ); |
681 | - } |
|
682 | - elseif (is_array($group_value)) { |
|
674 | + } elseif (is_array($group_value)) { |
|
683 | 675 | $group_value = 'array_' . hash( 'crc32b', var_export($group_value, true) ); |
684 | 676 | } |
685 | 677 |