@@ -32,8 +32,9 @@ |
||
32 | 32 | */ |
33 | 33 | function attributes() { |
34 | 34 | $attrs = function($object) { |
35 | - if (is_object($object)) |
|
36 | - return get_object_vars($object); |
|
35 | + if (is_object($object)) { |
|
36 | + return get_object_vars($object); |
|
37 | + } |
|
37 | 38 | return $object; |
38 | 39 | }; |
39 | 40 | return apply(curry($attrs), func_get_args()); |
@@ -128,8 +128,9 @@ discard block |
||
128 | 128 | * @return mixed |
129 | 129 | */ |
130 | 130 | function head($list) { |
131 | - if(is_string($list)) |
|
132 | - return substr($list, 0, 1); |
|
131 | + if(is_string($list)) { |
|
132 | + return substr($list, 0, 1); |
|
133 | + } |
|
133 | 134 | return (count($list) > 0) |
134 | 135 | ? $list[0] |
135 | 136 | : null; |
@@ -150,8 +151,9 @@ discard block |
||
150 | 151 | * @return mixed |
151 | 152 | */ |
152 | 153 | function last($list) { |
153 | - if(is_string($list)) |
|
154 | - return substr($list, -1); |
|
154 | + if(is_string($list)) { |
|
155 | + return substr($list, -1); |
|
156 | + } |
|
155 | 157 | return (count($list) > 0) |
156 | 158 | ? $list[count($list) - 1] |
157 | 159 | : null; |
@@ -173,10 +175,11 @@ discard block |
||
173 | 175 | * @return array |
174 | 176 | */ |
175 | 177 | function init($list) { |
176 | - if(is_string($list)) |
|
177 | - return (strlen($list) > 1) |
|
178 | + if(is_string($list)) { |
|
179 | + return (strlen($list) > 1) |
|
178 | 180 | ? substr($list, 0, strlen($list) - 1) |
179 | 181 | : ''; |
182 | + } |
|
180 | 183 | return (count($list) > 1) |
181 | 184 | ? array_slice($list, 0, count($list) - 1) |
182 | 185 | : []; |
@@ -198,10 +201,11 @@ discard block |
||
198 | 201 | * @return array |
199 | 202 | */ |
200 | 203 | function tail($list) { |
201 | - if(is_string($list)) |
|
202 | - return (strlen($list) > 1) |
|
204 | + if(is_string($list)) { |
|
205 | + return (strlen($list) > 1) |
|
203 | 206 | ? substr($list, 1) |
204 | 207 | : ''; |
208 | + } |
|
205 | 209 | return (count($list) > 1) |
206 | 210 | ? array_slice($list, 1) |
207 | 211 | : []; |
@@ -299,8 +303,9 @@ discard block |
||
299 | 303 | */ |
300 | 304 | function concat() { |
301 | 305 | $concat = function($list1, $list2) { |
302 | - if (is_string($list1)) |
|
303 | - return $list1 . $list2; |
|
306 | + if (is_string($list1)) { |
|
307 | + return $list1 . $list2; |
|
308 | + } |
|
304 | 309 | return array_merge($list1, $list2); |
305 | 310 | }; |
306 | 311 | return apply(curry($concat), func_get_args()); |
@@ -372,8 +377,9 @@ discard block |
||
372 | 377 | */ |
373 | 378 | function insertAll() { |
374 | 379 | $insertAll = function($position, $items, $list) { |
375 | - if ($position < 0) |
|
376 | - $position = length($list) - $position; |
|
380 | + if ($position < 0) { |
|
381 | + $position = length($list) - $position; |
|
382 | + } |
|
377 | 383 | return concatAll([take($position, $list), $items, remove($position, $list)]); |
378 | 384 | }; |
379 | 385 | return apply(curry($insertAll), func_get_args()); |
@@ -437,8 +443,9 @@ discard block |
||
437 | 443 | */ |
438 | 444 | function take() { |
439 | 445 | $take = function($count, $list) { |
440 | - if ($count > $length || $count < -$length) |
|
441 | - return []; |
|
446 | + if ($count > $length || $count < -$length) { |
|
447 | + return []; |
|
448 | + } |
|
442 | 449 | if(is_string($list)) { |
443 | 450 | return ($count >= 0) |
444 | 451 | ? substr($list, 0, $count) |
@@ -563,8 +570,9 @@ discard block |
||
563 | 570 | function remove() { |
564 | 571 | $remove = function($count, $list) { |
565 | 572 | $length = length($list); |
566 | - if ($count > $length || $count < -$length) |
|
567 | - return []; |
|
573 | + if ($count > $length || $count < -$length) { |
|
574 | + return []; |
|
575 | + } |
|
568 | 576 | return ($count > 0) |
569 | 577 | ? take($count - $length) |
570 | 578 | : take($count + $length); |
@@ -695,10 +703,12 @@ discard block |
||
695 | 703 | */ |
696 | 704 | function slices() { |
697 | 705 | $slices = function($size, $list) { |
698 | - if(empty($list)) |
|
699 | - return is_string($list) ? '' : []; |
|
700 | - if(length($list) <= $size) |
|
701 | - return [$list]; |
|
706 | + if(empty($list)) { |
|
707 | + return is_string($list) ? '' : []; |
|
708 | + } |
|
709 | + if(length($list) <= $size) { |
|
710 | + return [$list]; |
|
711 | + } |
|
702 | 712 | return prepend(take($size, $list), slices($size, remove($size, $list))); |
703 | 713 | }; |
704 | 714 | return apply(curry($slices), func_get_args()); |
@@ -744,8 +754,9 @@ discard block |
||
744 | 754 | function findIndex() { |
745 | 755 | $findIndex = function($predicate, $list) { |
746 | 756 | foreach ($list as $key => $value) { |
747 | - if ($predicate($value)) |
|
748 | - return $key; |
|
757 | + if ($predicate($value)) { |
|
758 | + return $key; |
|
759 | + } |
|
749 | 760 | } |
750 | 761 | return null; |
751 | 762 | }; |
@@ -770,8 +781,9 @@ discard block |
||
770 | 781 | function findLastIndex() { |
771 | 782 | $findLastIndex = function($predicate, $list) { |
772 | 783 | foreach (reverse(toPairs($list)) as $pair) { |
773 | - if($predicate($pair[1])) |
|
774 | - return $pair[0]; |
|
784 | + if($predicate($pair[1])) { |
|
785 | + return $pair[0]; |
|
786 | + } |
|
775 | 787 | } |
776 | 788 | return null; |
777 | 789 | }; |
@@ -959,8 +971,9 @@ discard block |
||
959 | 971 | $groupBy = function($fn, $list) { |
960 | 972 | return reduce(function($result, $item) use($fn) { |
961 | 973 | $index = $fn($item); |
962 | - if (! isset($result[$index])) |
|
963 | - $result[$index] = []; |
|
974 | + if (! isset($result[$index])) { |
|
975 | + $result[$index] = []; |
|
976 | + } |
|
964 | 977 | $result[$index][] = $item; |
965 | 978 | return $result; |
966 | 979 | }, [], $list); |
@@ -97,8 +97,9 @@ |
||
97 | 97 | function equals() { |
98 | 98 | $equals = function($a, $b) { |
99 | 99 | $type = type($a); |
100 | - if ($type != type($b)) |
|
101 | - return false; |
|
100 | + if ($type != type($b)) { |
|
101 | + return false; |
|
102 | + } |
|
102 | 103 | switch ($type) { |
103 | 104 | case 'Null': |
104 | 105 | case 'Boolean': |