From 174c0e545312a13c49bef36c9e9e98ac384dcf87 Mon Sep 17 00:00:00 2001 From: Piiotr Krzempek Date: Thu, 19 Nov 2020 11:43:17 +0100 Subject: [PATCH] style fix --- src/Illuminate/Collections/Arr.php | 15 ++++++--------- tests/Support/SupportArrTest.php | 4 ++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Illuminate/Collections/Arr.php b/src/Illuminate/Collections/Arr.php index 7c287d4c81ed..11c53cdb0712 100644 --- a/src/Illuminate/Collections/Arr.php +++ b/src/Illuminate/Collections/Arr.php @@ -688,22 +688,19 @@ public static function wrap($value) */ public static function sortByMany($array, $comparisons = []) { - usort($array, function($a, $b) use($comparisons) { - - foreach($comparisons as $cmp) - { + usort($array, function ($a, $b) use ($comparisons) { + foreach ($comparisons as $cmp) { // destruct comparison array to variables // with order set by default to 1 [$prop, $ascending] = static::wrap($cmp) + [1 => true]; $result = 0; - if(is_callable($prop)) { + if (is_callable($prop)) { $result = $prop($a, $b); - } - else { + } else { $values = [static::get($a, $prop), static::get($b, $prop)]; - if(!$ascending) { + if (! $ascending) { $values = array_reverse($values); } @@ -712,7 +709,7 @@ public static function sortByMany($array, $comparisons = []) // if result is 0, values are equal // so we have to order items by next comparison - if($result === 0) { + if ($result === 0) { continue; } diff --git a/tests/Support/SupportArrTest.php b/tests/Support/SupportArrTest.php index e50922930d11..73871670e35b 100644 --- a/tests/Support/SupportArrTest.php +++ b/tests/Support/SupportArrTest.php @@ -941,10 +941,10 @@ public function testSortByMany() // sort using callable $sortedWithCallable = array_values(Arr::sortByMany($unsorted, [ - function($a, $b) { + function ($a, $b) { return $a['name'] <=> $b['name']; }, - function($a, $b) { + function ($a, $b) { return $b['age'] <=> $a['age']; }, ['meta.key', true],