@@ -19,8 +19,6 @@ discard block |
||
| 19 | 19 | * ``` |
| 20 | 20 | * |
| 21 | 21 | * @signature String|Number -> [key => *] -> * |
| 22 | - * @param string $name |
|
| 23 | - * @param array $array |
|
| 24 | 22 | * @return mixed |
| 25 | 23 | */ |
| 26 | 24 | function value() { |
@@ -52,8 +50,6 @@ discard block |
||
| 52 | 50 | * ``` |
| 53 | 51 | * |
| 54 | 52 | * @signature String|Number -> [key => *] -> Boolean |
| 55 | - * @param string $name |
|
| 56 | - * @param array $array |
|
| 57 | 53 | * @return mixed |
| 58 | 54 | */ |
| 59 | 55 | function has() { |
@@ -112,8 +112,9 @@ discard block |
||
| 112 | 112 | * @return mixed |
| 113 | 113 | */ |
| 114 | 114 | function head($list) { |
| 115 | - if(is_string($list)) |
|
| 116 | - return substr($list, 0, 1); |
|
| 115 | + if(is_string($list)) { |
|
| 116 | + return substr($list, 0, 1); |
|
| 117 | + } |
|
| 117 | 118 | return (count($list) > 0) |
| 118 | 119 | ? $list[0] |
| 119 | 120 | : null; |
@@ -134,8 +135,9 @@ discard block |
||
| 134 | 135 | * @return mixed |
| 135 | 136 | */ |
| 136 | 137 | function last($list) { |
| 137 | - if(is_string($list)) |
|
| 138 | - return substr($list, -1); |
|
| 138 | + if(is_string($list)) { |
|
| 139 | + return substr($list, -1); |
|
| 140 | + } |
|
| 139 | 141 | return (count($list) > 0) |
| 140 | 142 | ? $list[count($list) - 1] |
| 141 | 143 | : null; |
@@ -157,10 +159,11 @@ discard block |
||
| 157 | 159 | * @return array |
| 158 | 160 | */ |
| 159 | 161 | function init($list) { |
| 160 | - if(is_string($list)) |
|
| 161 | - return (strlen($list) > 1) |
|
| 162 | + if(is_string($list)) { |
|
| 163 | + return (strlen($list) > 1) |
|
| 162 | 164 | ? substr($list, 0, strlen($list) - 1) |
| 163 | 165 | : ''; |
| 166 | + } |
|
| 164 | 167 | return (count($list) > 1) |
| 165 | 168 | ? array_slice($list, 0, count($list) - 1) |
| 166 | 169 | : []; |
@@ -182,10 +185,11 @@ discard block |
||
| 182 | 185 | * @return array |
| 183 | 186 | */ |
| 184 | 187 | function tail($list) { |
| 185 | - if(is_string($list)) |
|
| 186 | - return (strlen($list) > 1) |
|
| 188 | + if(is_string($list)) { |
|
| 189 | + return (strlen($list) > 1) |
|
| 187 | 190 | ? substr($list, 1) |
| 188 | 191 | : ''; |
| 192 | + } |
|
| 189 | 193 | return (count($list) > 1) |
| 190 | 194 | ? array_slice($list, 1) |
| 191 | 195 | : []; |
@@ -283,8 +287,9 @@ discard block |
||
| 283 | 287 | */ |
| 284 | 288 | function concat() { |
| 285 | 289 | $concat = function($list1, $list2) { |
| 286 | - if (is_string($list1)) |
|
| 287 | - return $list1 . $list2; |
|
| 290 | + if (is_string($list1)) { |
|
| 291 | + return $list1 . $list2; |
|
| 292 | + } |
|
| 288 | 293 | return array_merge($list1, $list2); |
| 289 | 294 | }; |
| 290 | 295 | return apply(curry($concat), func_get_args()); |
@@ -306,8 +311,9 @@ discard block |
||
| 306 | 311 | */ |
| 307 | 312 | function append() { |
| 308 | 313 | $append = function ($item, $list) { |
| 309 | - if (is_string($list)) |
|
| 310 | - return $list . $item; |
|
| 314 | + if (is_string($list)) { |
|
| 315 | + return $list . $item; |
|
| 316 | + } |
|
| 311 | 317 | return array_merge($list, [$item]); |
| 312 | 318 | }; |
| 313 | 319 | return apply(curry($append), func_get_args()); |
@@ -329,8 +335,9 @@ discard block |
||
| 329 | 335 | */ |
| 330 | 336 | function prepend() { |
| 331 | 337 | $prepend = function ($item, $list) { |
| 332 | - if (is_string($list)) |
|
| 333 | - return $item . $list; |
|
| 338 | + if (is_string($list)) { |
|
| 339 | + return $item . $list; |
|
| 340 | + } |
|
| 334 | 341 | return array_merge([$item], $list); |
| 335 | 342 | }; |
| 336 | 343 | return apply(curry($prepend), func_get_args()); |
@@ -451,10 +458,12 @@ discard block |
||
| 451 | 458 | */ |
| 452 | 459 | function slices() { |
| 453 | 460 | $slices = function($size, $list) { |
| 454 | - if(empty($list)) |
|
| 455 | - return is_string($list) ? '' : []; |
|
| 456 | - if(length($list) <= $size) |
|
| 457 | - return [$list]; |
|
| 461 | + if(empty($list)) { |
|
| 462 | + return is_string($list) ? '' : []; |
|
| 463 | + } |
|
| 464 | + if(length($list) <= $size) { |
|
| 465 | + return [$list]; |
|
| 466 | + } |
|
| 458 | 467 | return prepend(take($size, $list), slices($size, remove($size, $list))); |
| 459 | 468 | }; |
| 460 | 469 | return apply(curry($slices), func_get_args()); |
@@ -477,8 +486,9 @@ discard block |
||
| 477 | 486 | */ |
| 478 | 487 | function contains() { |
| 479 | 488 | $contains = function($item, $list) { |
| 480 | - if(is_string($list)) |
|
| 481 | - return false !== strpos($list, $item); |
|
| 489 | + if(is_string($list)) { |
|
| 490 | + return false !== strpos($list, $item); |
|
| 491 | + } |
|
| 482 | 492 | return in_array($item, $list); |
| 483 | 493 | }; |
| 484 | 494 | return apply(curry($contains), func_get_args()); |