@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | * @param callable $predicate the filter function |
| 113 | 113 | * @return \Closure |
| 114 | 114 | */ |
| 115 | -function _make_filterer (callable $append, callable $predicate) { |
|
| 116 | - return function ($acc, ...$entry) use ($append, $predicate) { |
|
| 115 | +function _make_filterer(callable $append, callable $predicate) { |
|
| 116 | + return function($acc, ...$entry) use ($append, $predicate) { |
|
| 117 | 117 | if ($predicate($entry[0])) { |
| 118 | 118 | $append($acc, ...$entry); |
| 119 | 119 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | function reduce() { |
| 204 | 204 | static $reduce = false; |
| 205 | - $reduce = $reduce ?: curry(function($fn, $initial, $list){ |
|
| 205 | + $reduce = $reduce ?: curry(function($fn, $initial, $list) { |
|
| 206 | 206 | return array_reduce($list, $fn, $initial); |
| 207 | 207 | }); |
| 208 | 208 | return _apply($reduce, func_get_args()); |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | function each() { |
| 231 | 231 | static $each = false; |
| 232 | - $each = $each ?: curry(function($fn, $list){ |
|
| 232 | + $each = $each ?: curry(function($fn, $list) { |
|
| 233 | 233 | foreach ($list as $item) { |
| 234 | 234 | $fn($item); |
| 235 | 235 | } |
@@ -279,10 +279,10 @@ discard block |
||
| 279 | 279 | * @param array|string $list |
| 280 | 280 | * @return mixed |
| 281 | 281 | */ |
| 282 | -function last () { |
|
| 282 | +function last() { |
|
| 283 | 283 | static $last = false; |
| 284 | 284 | $last = $last ?: curry(function($list) { |
| 285 | - if(is_string($list)) |
|
| 285 | + if (is_string($list)) |
|
| 286 | 286 | return substr($list, -1); |
| 287 | 287 | $size = count($list); |
| 288 | 288 | return ($size > 0) |
@@ -309,10 +309,10 @@ discard block |
||
| 309 | 309 | * @param array|string $list |
| 310 | 310 | * @return array |
| 311 | 311 | */ |
| 312 | -function init () { |
|
| 312 | +function init() { |
|
| 313 | 313 | static $init = false; |
| 314 | 314 | $init = $init ?: curry(function($list) { |
| 315 | - if(is_string($list)) { |
|
| 315 | + if (is_string($list)) { |
|
| 316 | 316 | $size = strlen($list); |
| 317 | 317 | return ($size > 1) |
| 318 | 318 | ? substr($list, 0, $size - 1) |
@@ -343,10 +343,10 @@ discard block |
||
| 343 | 343 | * @param array|string $list |
| 344 | 344 | * @return array |
| 345 | 345 | */ |
| 346 | -function tail () { |
|
| 346 | +function tail() { |
|
| 347 | 347 | static $tail = false; |
| 348 | 348 | $tail = $tail ?: curry(function($list) { |
| 349 | - if(is_string($list)) |
|
| 349 | + if (is_string($list)) |
|
| 350 | 350 | return (strlen($list) > 1) |
| 351 | 351 | ? substr($list, 1) |
| 352 | 352 | : ''; |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | * @param array|string $list |
| 372 | 372 | * @return array |
| 373 | 373 | */ |
| 374 | -function reverse () { |
|
| 374 | +function reverse() { |
|
| 375 | 375 | static $reverse = false; |
| 376 | 376 | $reverse = $reverse ?: curry(function($list) { |
| 377 | 377 | return is_string($list) |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | static $allSatisfies = false; |
| 425 | 425 | $allSatisfies = $allSatisfies ?: curry(function($predicate, $list) { |
| 426 | 426 | foreach ($list as $item) { |
| 427 | - if (! $predicate($item)) |
|
| 427 | + if (!$predicate($item)) |
|
| 428 | 428 | return false; |
| 429 | 429 | } |
| 430 | 430 | return true; |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | */ |
| 601 | 601 | function append() { |
| 602 | 602 | static $append = false; |
| 603 | - $append = $append ?: curry(function ($item, $list) { |
|
| 603 | + $append = $append ?: curry(function($item, $list) { |
|
| 604 | 604 | return is_string($list) |
| 605 | 605 | ? $list . $item |
| 606 | 606 | : array_merge($list, [$item]); |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | */ |
| 627 | 627 | function prepend() { |
| 628 | 628 | static $prepend = false; |
| 629 | - $prepend = $prepend ?: curry(function ($item, $list) { |
|
| 629 | + $prepend = $prepend ?: curry(function($item, $list) { |
|
| 630 | 630 | return is_string($list) |
| 631 | 631 | ? $item . $list |
| 632 | 632 | : array_merge([$item], $list); |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | $length = length($list); |
| 662 | 662 | if ($count > $length || $count < -$length) |
| 663 | 663 | return $list; |
| 664 | - if(is_string($list)) { |
|
| 664 | + if (is_string($list)) { |
|
| 665 | 665 | return ($count >= 0) |
| 666 | 666 | ? substr($list, 0, $count) |
| 667 | 667 | : substr($list, $count); |
@@ -812,7 +812,7 @@ discard block |
||
| 812 | 812 | $count = ($count > 0) |
| 813 | 813 | ? $count - $length |
| 814 | 814 | : $count + $length; |
| 815 | - if(is_string($list)) { |
|
| 815 | + if (is_string($list)) { |
|
| 816 | 816 | return ($count >= 0) |
| 817 | 817 | ? substr($list, 0, $count) |
| 818 | 818 | : substr($list, $count); |
@@ -1169,7 +1169,7 @@ discard block |
||
| 1169 | 1169 | $indexOf = $indexOf ?: curry(function($item, $list) { |
| 1170 | 1170 | if (is_string($list)) { |
| 1171 | 1171 | $index = strpos($list, $item); |
| 1172 | - return $index === false ? -1 : $index; |
|
| 1172 | + return $index === false ? - 1 : $index; |
|
| 1173 | 1173 | } |
| 1174 | 1174 | $list = (array) $list; |
| 1175 | 1175 | $index = 0; |
@@ -1180,7 +1180,7 @@ discard block |
||
| 1180 | 1180 | return $keys[$index]; |
| 1181 | 1181 | $index ++; |
| 1182 | 1182 | } |
| 1183 | - return -1; |
|
| 1183 | + return - 1; |
|
| 1184 | 1184 | }); |
| 1185 | 1185 | return _apply($indexOf, func_get_args()); |
| 1186 | 1186 | } |
@@ -1209,7 +1209,7 @@ discard block |
||
| 1209 | 1209 | $lastIndexOf = $lastIndexOf ?: curry(function($item, $list) { |
| 1210 | 1210 | if (is_string($list)) { |
| 1211 | 1211 | $index = strrpos($list, $item); |
| 1212 | - return $index === false ? -1 : $index; |
|
| 1212 | + return $index === false ? - 1 : $index; |
|
| 1213 | 1213 | } |
| 1214 | 1214 | $list = (array) $list; |
| 1215 | 1215 | $keys = array_keys($list); |
@@ -1219,7 +1219,7 @@ discard block |
||
| 1219 | 1219 | return $keys[$index]; |
| 1220 | 1220 | $index --; |
| 1221 | 1221 | } |
| 1222 | - return -1; |
|
| 1222 | + return - 1; |
|
| 1223 | 1223 | }); |
| 1224 | 1224 | return _apply($lastIndexOf, func_get_args()); |
| 1225 | 1225 | } |
@@ -1254,7 +1254,7 @@ discard block |
||
| 1254 | 1254 | } |
| 1255 | 1255 | $index ++; |
| 1256 | 1256 | } |
| 1257 | - if (! $found) { |
|
| 1257 | + if (!$found) { |
|
| 1258 | 1258 | $result[$size] = $item; |
| 1259 | 1259 | $size ++; |
| 1260 | 1260 | } |
@@ -1314,9 +1314,9 @@ discard block |
||
| 1314 | 1314 | static $groupBy = false; |
| 1315 | 1315 | $groupBy = $groupBy ?: curry(function($fn, $list) { |
| 1316 | 1316 | $result = []; |
| 1317 | - foreach($list as $item) { |
|
| 1317 | + foreach ($list as $item) { |
|
| 1318 | 1318 | $index = $fn($item); |
| 1319 | - if (! isset($result[$index])) |
|
| 1319 | + if (!isset($result[$index])) |
|
| 1320 | 1320 | $result[$index] = []; |
| 1321 | 1321 | $result[$index][] = $item; |
| 1322 | 1322 | } |