@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | public static function concat(string $delimiter = ''): Closure |
| 26 | 26 | { |
| 27 | - return static function (Collection $collection) use ($delimiter) { |
|
| 27 | + return static function(Collection $collection) use ($delimiter) { |
|
| 28 | 28 | return implode($delimiter, $collection->toArray()); |
| 29 | 29 | }; |
| 30 | 30 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @param Collection $collection |
| 40 | 40 | * @return float|int |
| 41 | 41 | */ |
| 42 | - return static function (Collection $collection) { |
|
| 42 | + return static function(Collection $collection) { |
|
| 43 | 43 | $array = $collection->toArray(); |
| 44 | 44 | |
| 45 | 45 | return array_sum($array) / count($array); |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public static function group(): Closure |
| 54 | 54 | { |
| 55 | - return static function (Collection $collection): Map { |
|
| 56 | - $groupBy = self::groupBy(static function ($el) { |
|
| 55 | + return static function(Collection $collection): Map { |
|
| 56 | + $groupBy = self::groupBy(static function($el) { |
|
| 57 | 57 | return $el; |
| 58 | 58 | }); |
| 59 | 59 | return $groupBy($collection); |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public static function groupByProperty(string $property): Closure |
| 69 | 69 | { |
| 70 | - return static function (Collection $collection) use ($property): Map { |
|
| 71 | - $fGetValue = static function ($obj) use ($property) { |
|
| 70 | + return static function(Collection $collection) use ($property): Map { |
|
| 71 | + $fGetValue = static function($obj) use ($property) { |
|
| 72 | 72 | return ObjectFunctions::getPropertyValue($obj, $property); |
| 73 | 73 | }; |
| 74 | 74 | |
@@ -84,11 +84,11 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public static function groupBy(callable $f): Closure |
| 86 | 86 | { |
| 87 | - return static function (Collection $collection) use ($f): Map { |
|
| 87 | + return static function(Collection $collection) use ($f): Map { |
|
| 88 | 88 | $group = new HashMap(); |
| 89 | 89 | $collection |
| 90 | 90 | ->stream() |
| 91 | - ->each(static function ($el) use ($group, $f) { |
|
| 91 | + ->each(static function($el) use ($group, $f) { |
|
| 92 | 92 | $value = $f($el); |
| 93 | 93 | $count = 0; |
| 94 | 94 | if (($gCount = $group->get($value)) !== null) { |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public static function dump(): callable |
| 15 | 15 | { |
| 16 | - return static function ($el) { |
|
| 16 | + return static function($el) { |
|
| 17 | 17 | var_dump($el); |
| 18 | 18 | }; |
| 19 | 19 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | public static function lock(): Closure |
| 18 | 18 | { |
| 19 | - return static function (): bool { |
|
| 19 | + return static function(): bool { |
|
| 20 | 20 | return false; |
| 21 | 21 | }; |
| 22 | 22 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public static function notNull(): Closure |
| 29 | 29 | { |
| 30 | - return static function ($el): bool { |
|
| 30 | + return static function($el): bool { |
|
| 31 | 31 | return $el !== null; |
| 32 | 32 | }; |
| 33 | 33 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public static function notResistance(): Closure |
| 40 | 40 | { |
| 41 | - return static function (): bool { |
|
| 41 | + return static function(): bool { |
|
| 42 | 42 | return true; |
| 43 | 43 | }; |
| 44 | 44 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | public static function eachEven(): Closure |
| 51 | 51 | { |
| 52 | 52 | $isEven = false; |
| 53 | - return static function () use (& $isEven) { |
|
| 53 | + return static function() use (& $isEven) { |
|
| 54 | 54 | $res = $isEven; |
| 55 | 55 | $isEven = !$isEven; |
| 56 | 56 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | public static function nth($number): Closure |
| 67 | 67 | { |
| 68 | 68 | $counter = 0; |
| 69 | - return static function () use ($number, & $counter) { |
|
| 69 | + return static function() use ($number, & $counter) { |
|
| 70 | 70 | $res = ++$counter % $number === 0; |
| 71 | 71 | if ($res) { |
| 72 | 72 | $counter = 0; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public static function equal($value): Closure |
| 84 | 84 | { |
| 85 | - return static function ($el) use ($value): bool { |
|
| 85 | + return static function($el) use ($value): bool { |
|
| 86 | 86 | return $el === $value; |
| 87 | 87 | }; |
| 88 | 88 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public static function lessThan($value): Closure |
| 96 | 96 | { |
| 97 | - return static function ($el) use ($value): bool { |
|
| 97 | + return static function($el) use ($value): bool { |
|
| 98 | 98 | return $el < $value; |
| 99 | 99 | }; |
| 100 | 100 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public static function lessOrEqual($value): Closure |
| 108 | 108 | { |
| 109 | - return static function ($el) use ($value): bool { |
|
| 109 | + return static function($el) use ($value): bool { |
|
| 110 | 110 | return $el <= $value; |
| 111 | 111 | }; |
| 112 | 112 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public static function moreThan($value): Closure |
| 120 | 120 | { |
| 121 | - return static function ($el) use ($value): bool { |
|
| 121 | + return static function($el) use ($value): bool { |
|
| 122 | 122 | return $el > $value; |
| 123 | 123 | }; |
| 124 | 124 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public static function moreOrEqual($value): Closure |
| 132 | 132 | { |
| 133 | - return static function ($el) use ($value): bool { |
|
| 133 | + return static function($el) use ($value): bool { |
|
| 134 | 134 | return $el >= $value; |
| 135 | 135 | }; |
| 136 | 136 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | public static function not($value): Closure |
| 144 | 144 | { |
| 145 | - return static function ($el) use ($value): bool { |
|
| 145 | + return static function($el) use ($value): bool { |
|
| 146 | 146 | return $el !== $value; |
| 147 | 147 | }; |
| 148 | 148 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | public static function in(array $values): Closure |
| 156 | 156 | { |
| 157 | - return static function ($el) use ($values): bool { |
|
| 157 | + return static function($el) use ($values): bool { |
|
| 158 | 158 | return in_array($el, $values, true); |
| 159 | 159 | }; |
| 160 | 160 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | public static function notIn(array $values): Closure |
| 168 | 168 | { |
| 169 | - return static function ($el) use ($values): bool { |
|
| 169 | + return static function($el) use ($values): bool { |
|
| 170 | 170 | return !in_array($el, $values, true); |
| 171 | 171 | }; |
| 172 | 172 | } |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public static function where(string $property, $value): Closure |
| 181 | 181 | { |
| 182 | - return static function ($ob) use ($property, $value) { |
|
| 182 | + return static function($ob) use ($property, $value) { |
|
| 183 | 183 | return $value === ObjectFunctions::getPropertyValue($ob, $property); |
| 184 | 184 | }; |
| 185 | 185 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | public static function whereNot(string $property, $value): Closure |
| 194 | 194 | { |
| 195 | - return static function ($ob) use ($property, $value) { |
|
| 195 | + return static function($ob) use ($property, $value) { |
|
| 196 | 196 | return $value !== ObjectFunctions::getPropertyValue($ob, $property); |
| 197 | 197 | }; |
| 198 | 198 | } |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | public static function whereIn(string $property, array $values): Closure |
| 207 | 207 | { |
| 208 | - return static function ($ob) use ($property, $values) { |
|
| 208 | + return static function($ob) use ($property, $values) { |
|
| 209 | 209 | return in_array(ObjectFunctions::getPropertyValue($ob, $property), $values, true); |
| 210 | 210 | }; |
| 211 | 211 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | public static function whereNotIn(string $property, array $values): Closure |
| 220 | 220 | { |
| 221 | - return static function ($ob) use ($property, $values) { |
|
| 221 | + return static function($ob) use ($property, $values) { |
|
| 222 | 222 | return !in_array(ObjectFunctions::getPropertyValue($ob, $property), $values, true); |
| 223 | 223 | }; |
| 224 | 224 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | public static function whereMoreThan(string $property, $value): Closure |
| 233 | 233 | { |
| 234 | - return static function (object $ob) use ($property, $value) { |
|
| 234 | + return static function(object $ob) use ($property, $value) { |
|
| 235 | 235 | return ObjectFunctions::getPropertyValue($ob, $property) > $value; |
| 236 | 236 | }; |
| 237 | 237 | } |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | public static function whereLessThan(string $property, $value): Closure |
| 246 | 246 | { |
| 247 | - return static function (object $ob) use ($property, $value) { |
|
| 247 | + return static function(object $ob) use ($property, $value) { |
|
| 248 | 248 | return ObjectFunctions::getPropertyValue($ob, $property) < $value; |
| 249 | 249 | }; |
| 250 | 250 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | */ |
| 258 | 258 | public static function whereMoreOrEqual(string $property, $value): Closure |
| 259 | 259 | { |
| 260 | - return static function (object $ob) use ($property, $value) { |
|
| 260 | + return static function(object $ob) use ($property, $value) { |
|
| 261 | 261 | return ObjectFunctions::getPropertyValue($ob, $property) >= $value; |
| 262 | 262 | }; |
| 263 | 263 | } |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | */ |
| 271 | 271 | public static function whereLessOrEqual(string $property, $value): Closure |
| 272 | 272 | { |
| 273 | - return static function (object $ob) use ($property, $value) { |
|
| 273 | + return static function(object $ob) use ($property, $value) { |
|
| 274 | 274 | return ObjectFunctions::getPropertyValue($ob, $property) <= $value; |
| 275 | 275 | }; |
| 276 | 276 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public static function shuffle(): Closure |
| 23 | 23 | { |
| 24 | - return static function (Collection $collection): Collection { |
|
| 24 | + return static function(Collection $collection): Collection { |
|
| 25 | 25 | $array = $collection->toArray(); |
| 26 | 26 | shuffle($array); |
| 27 | 27 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public static function random(int $count = 1): Closure |
| 38 | 38 | { |
| 39 | - return static function (Collection $collection) use ($count): Collection { |
|
| 39 | + return static function(Collection $collection) use ($count): Collection { |
|
| 40 | 40 | /** |
| 41 | 41 | * Collection |
| 42 | 42 | */ |
@@ -56,11 +56,11 @@ discard block |
||
| 56 | 56 | $generated = 0; |
| 57 | 57 | $multiplicity = (int)round($collectionSize / $expectedCount); |
| 58 | 58 | |
| 59 | - $rangeRandomizer = static function () use ($multiplicity): int { |
|
| 59 | + $rangeRandomizer = static function() use ($multiplicity): int { |
|
| 60 | 60 | return random_int(0, $multiplicity - 1); |
| 61 | 61 | }; |
| 62 | 62 | |
| 63 | - $trier = static function () use (& $generated, & $rest, $expectedCount, $rangeRandomizer): bool { |
|
| 63 | + $trier = static function() use (& $generated, & $rest, $expectedCount, $rangeRandomizer): bool { |
|
| 64 | 64 | $rest--; |
| 65 | 65 | if ($generated === $expectedCount) { |
| 66 | 66 | return false; |
@@ -89,13 +89,13 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public static function chunk(int $size): Closure |
| 91 | 91 | { |
| 92 | - return static function (Collection $collection) use ($size): Collection { |
|
| 92 | + return static function(Collection $collection) use ($size): Collection { |
|
| 93 | 93 | $chunkCollection = self::collectionConstructor(); |
| 94 | 94 | $currentChunk = self::collectionConstructor(); |
| 95 | 95 | $pointer = $size; |
| 96 | 96 | $collection |
| 97 | 97 | ->stream() |
| 98 | - ->each(static function ($el) use ($size, $chunkCollection, & $currentChunk, & $pointer) { |
|
| 98 | + ->each(static function($el) use ($size, $chunkCollection, & $currentChunk, & $pointer) { |
|
| 99 | 99 | $pointer--; |
| 100 | 100 | $currentChunk->add($el); |
| 101 | 101 | |
@@ -116,8 +116,8 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public static function collapse(): Closure |
| 118 | 118 | { |
| 119 | - return static function (Collection $collection): Collection { |
|
| 120 | - $flatIterable = static function (iterable $collection) use (& $flatIterable): array { |
|
| 119 | + return static function(Collection $collection): Collection { |
|
| 120 | + $flatIterable = static function(iterable $collection) use (& $flatIterable): array { |
|
| 121 | 121 | $res = []; |
| 122 | 122 | foreach ($collection as $item) { |
| 123 | 123 | if (is_iterable($item)) { |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public static function scalarComparator(): Closure |
| 17 | 17 | { |
| 18 | - return static function ($a, $b) { |
|
| 18 | + return static function($a, $b) { |
|
| 19 | 19 | return $a <=> $b; |
| 20 | 20 | }; |
| 21 | 21 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public static function objectPropertyComparator(string $property): Closure |
| 29 | 29 | { |
| 30 | - return static function ($a, $b) use ($property) { |
|
| 30 | + return static function($a, $b) use ($property) { |
|
| 31 | 31 | return ObjectFunctions::getPropertyValue($a, $property) <=> ObjectFunctions::getPropertyValue($b, $property); |
| 32 | 32 | }; |
| 33 | 33 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public static function callbackComparator(callable $f): Closure |
| 41 | 41 | { |
| 42 | - return static function ($a, $b) use ($f) { |
|
| 42 | + return static function($a, $b) use ($f) { |
|
| 43 | 43 | return $f($a) <=> $f($b); |
| 44 | 44 | }; |
| 45 | 45 | } |