@@ -84,11 +84,8 @@ public function avg($callback = null)
84
84
{
85
85
$ callback = $ this ->valueRetriever ($ callback );
86
86
87
- $ items = $ this ->map (function ($ value ) use ($ callback ) {
88
- return $ callback ($ value );
89
- })->filter (function ($ value ) {
90
- return ! is_null ($ value );
91
- });
87
+ $ items = $ this ->map (fn ($ value ) => $ callback ($ value ))
88
+ ->filter (fn ($ value ) => ! is_null ($ value ));
92
89
93
90
if ($ count = $ items ->count ()) {
94
91
return $ items ->sum () / $ count ;
@@ -349,14 +346,10 @@ public function duplicatesStrict($callback = null)
349
346
protected function duplicateComparator ($ strict )
350
347
{
351
348
if ($ strict ) {
352
- return function ($ a , $ b ) {
353
- return $ a === $ b ;
354
- };
349
+ return fn ($ a , $ b ) => $ a === $ b ;
355
350
}
356
351
357
- return function ($ a , $ b ) {
358
- return $ a == $ b ;
359
- };
352
+ return fn ($ a , $ b ) => $ a == $ b ;
360
353
}
361
354
362
355
/**
@@ -1151,9 +1144,7 @@ public function sliding($size = 2, $step = 1)
1151
1144
{
1152
1145
$ chunks = floor (($ this ->count () - $ size ) / $ step ) + 1 ;
1153
1146
1154
- return static ::times ($ chunks , function ($ number ) use ($ size , $ step ) {
1155
- return $ this ->slice (($ number - 1 ) * $ step , $ size );
1156
- });
1147
+ return static ::times ($ chunks , fn ($ number ) => $ this ->slice (($ number - 1 ) * $ step , $ size ));
1157
1148
}
1158
1149
1159
1150
/**
@@ -1634,13 +1625,9 @@ public function values()
1634
1625
*/
1635
1626
public function zip ($ items )
1636
1627
{
1637
- $ arrayableItems = array_map (function ($ items ) {
1638
- return $ this ->getArrayableItems ($ items );
1639
- }, func_get_args ());
1628
+ $ arrayableItems = array_map (fn ($ items ) => $ this ->getArrayableItems ($ items ), func_get_args ());
1640
1629
1641
- $ params = array_merge ([function () {
1642
- return new static (func_get_args ());
1643
- }, $ this ->items ], $ arrayableItems );
1630
+ $ params = array_merge ([fn () => new static (func_get_args ()), $ this ->items ], $ arrayableItems );
1644
1631
1645
1632
return new static (array_map (...$ params ));
1646
1633
}
0 commit comments