@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @return mixed |
101 | 101 | */ |
102 | 102 | function has() { |
103 | - $has = function($name, $object){ |
|
103 | + $has = function($name, $object) { |
|
104 | 104 | return contains($name, keys($object)); |
105 | 105 | }; |
106 | 106 | return apply(curry($has), func_get_args()); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @return mixed |
131 | 131 | */ |
132 | 132 | function get() { |
133 | - $get = function($name, $object){ |
|
133 | + $get = function($name, $object) { |
|
134 | 134 | $object = attributes($object); |
135 | 135 | return has($name, $object) |
136 | 136 | ? $object[$name] |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @return array |
57 | 57 | */ |
58 | 58 | function filter() { |
59 | - $filter = function($fn, $list){ |
|
59 | + $filter = function($fn, $list) { |
|
60 | 60 | return array_values(array_filter($list, $fn)); |
61 | 61 | }; |
62 | 62 | return apply(curry($filter), func_get_args()); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @return array |
79 | 79 | */ |
80 | 80 | function reduce() { |
81 | - $reduce = function($fn, $initial, $list){ |
|
81 | + $reduce = function($fn, $initial, $list) { |
|
82 | 82 | return array_reduce($list, $fn, $initial); |
83 | 83 | }; |
84 | 84 | return apply(curry($reduce), func_get_args()); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @return array |
105 | 105 | */ |
106 | 106 | function each() { |
107 | - $each = function($fn, $list){ |
|
107 | + $each = function($fn, $list) { |
|
108 | 108 | foreach ($list as $item) { |
109 | 109 | apply($fn, [$item]); |
110 | 110 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @return mixed |
129 | 129 | */ |
130 | 130 | function head($list) { |
131 | - if(is_string($list)) |
|
131 | + if (is_string($list)) |
|
132 | 132 | return substr($list, 0, 1); |
133 | 133 | return (count($list) > 0) |
134 | 134 | ? $list[0] |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @return mixed |
151 | 151 | */ |
152 | 152 | function last($list) { |
153 | - if(is_string($list)) |
|
153 | + if (is_string($list)) |
|
154 | 154 | return substr($list, -1); |
155 | 155 | return (count($list) > 0) |
156 | 156 | ? $list[count($list) - 1] |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @return array |
174 | 174 | */ |
175 | 175 | function init($list) { |
176 | - if(is_string($list)) |
|
176 | + if (is_string($list)) |
|
177 | 177 | return (strlen($list) > 1) |
178 | 178 | ? substr($list, 0, strlen($list) - 1) |
179 | 179 | : ''; |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @return array |
199 | 199 | */ |
200 | 200 | function tail($list) { |
201 | - if(is_string($list)) |
|
201 | + if (is_string($list)) |
|
202 | 202 | return (strlen($list) > 1) |
203 | 203 | ? substr($list, 1) |
204 | 204 | : ''; |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * @return array |
394 | 394 | */ |
395 | 395 | function append() { |
396 | - $append = function ($item, $list) { |
|
396 | + $append = function($item, $list) { |
|
397 | 397 | return concat($list, [$item]); |
398 | 398 | }; |
399 | 399 | return apply(curry($append), func_get_args()); |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | $take = function($count, $list) { |
440 | 440 | if ($count > $length || $count < -$length) |
441 | 441 | return []; |
442 | - if(is_string($list)) { |
|
442 | + if (is_string($list)) { |
|
443 | 443 | return ($count >= 0) |
444 | 444 | ? substr($list, 0, $count) |
445 | 445 | : substr($list, $count); |
@@ -695,9 +695,9 @@ discard block |
||
695 | 695 | */ |
696 | 696 | function slices() { |
697 | 697 | $slices = function($size, $list) { |
698 | - if(empty($list)) |
|
698 | + if (empty($list)) |
|
699 | 699 | return is_string($list) ? '' : []; |
700 | - if(length($list) <= $size) |
|
700 | + if (length($list) <= $size) |
|
701 | 701 | return [$list]; |
702 | 702 | return prepend(take($size, $list), slices($size, remove($size, $list))); |
703 | 703 | }; |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | function findLastIndex() { |
771 | 771 | $findLastIndex = function($predicate, $list) { |
772 | 772 | foreach (reverse(toPairs($list)) as $pair) { |
773 | - if($predicate($pair[1])) |
|
773 | + if ($predicate($pair[1])) |
|
774 | 774 | return $pair[0]; |
775 | 775 | } |
776 | 776 | return null; |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | $indexOf = function($item, $list) { |
843 | 843 | if (is_string($list)) { |
844 | 844 | $index = strpos($list, $item); |
845 | - return (-1 == $index) |
|
845 | + return (- 1 == $index) |
|
846 | 846 | ? null |
847 | 847 | : $index; |
848 | 848 | } |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | $lastIndexOf = function($item, $list) { |
872 | 872 | if (is_string($list)) { |
873 | 873 | $index = strrpos($list, $item); |
874 | - return (-1 == $index) |
|
874 | + return (- 1 == $index) |
|
875 | 875 | ? null |
876 | 876 | : $index; |
877 | 877 | } |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | $groupBy = function($fn, $list) { |
960 | 960 | return reduce(function($result, $item) use($fn) { |
961 | 961 | $index = $fn($item); |
962 | - if (! isset($result[$index])) |
|
962 | + if (!isset($result[$index])) |
|
963 | 963 | $result[$index] = []; |
964 | 964 | $result[$index][] = $item; |
965 | 965 | return $result; |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * @return bool |
14 | 14 | */ |
15 | 15 | function and_() { |
16 | - return apply(curry(function($a, $b){ |
|
16 | + return apply(curry(function($a, $b) { |
|
17 | 17 | return $a && $b; |
18 | 18 | }), func_get_args()); |
19 | 19 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @return bool |
28 | 28 | */ |
29 | 29 | function or_() { |
30 | - return apply(curry(function($a, $b){ |
|
30 | + return apply(curry(function($a, $b) { |
|
31 | 31 | return $a || $b; |
32 | 32 | }), func_get_args()); |
33 | 33 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @return bool |
56 | 56 | */ |
57 | 57 | function eq() { |
58 | - return apply(curry(function($a, $b){ |
|
58 | + return apply(curry(function($a, $b) { |
|
59 | 59 | return $a == $b; |
60 | 60 | }), func_get_args()); |
61 | 61 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @return bool |
70 | 70 | */ |
71 | 71 | function eqq() { |
72 | - return apply(curry(function($a, $b){ |
|
72 | + return apply(curry(function($a, $b) { |
|
73 | 73 | return $a === $b; |
74 | 74 | }), func_get_args()); |
75 | 75 | } |
@@ -112,9 +112,7 @@ discard block |
||
112 | 112 | return $a == $b; |
113 | 113 | case 'List': |
114 | 114 | $length = length($a); |
115 | - return length($b) != $length ? false : |
|
116 | - 0 == $length ? true : |
|
117 | - equals(head($a), head($b)) && equals(tail($a), tail($b)); |
|
115 | + return length($b) != $length ? false : 0 == $length ? true : equals(head($a), head($b)) && equals(tail($a), tail($b)); |
|
118 | 116 | case 'Array': |
119 | 117 | case 'ArrayObject': |
120 | 118 | case 'Object': |
@@ -134,7 +132,7 @@ discard block |
||
134 | 132 | * @return bool |
135 | 133 | */ |
136 | 134 | function lt() { |
137 | - return apply(curry(function($a, $b){ |
|
135 | + return apply(curry(function($a, $b) { |
|
138 | 136 | return $a < $b; |
139 | 137 | }), func_get_args()); |
140 | 138 | } |
@@ -148,7 +146,7 @@ discard block |
||
148 | 146 | * @return bool |
149 | 147 | */ |
150 | 148 | function lte() { |
151 | - return apply(curry(function($a, $b){ |
|
149 | + return apply(curry(function($a, $b) { |
|
152 | 150 | return $a <= $b; |
153 | 151 | }), func_get_args()); |
154 | 152 | } |
@@ -162,7 +160,7 @@ discard block |
||
162 | 160 | * @return bool |
163 | 161 | */ |
164 | 162 | function gt() { |
165 | - return apply(curry(function($a, $b){ |
|
163 | + return apply(curry(function($a, $b) { |
|
166 | 164 | return $a > $b; |
167 | 165 | }), func_get_args()); |
168 | 166 | } |
@@ -176,7 +174,7 @@ discard block |
||
176 | 174 | * @return bool |
177 | 175 | */ |
178 | 176 | function gte() { |
179 | - return apply(curry(function($a, $b){ |
|
177 | + return apply(curry(function($a, $b) { |
|
180 | 178 | return $a >= $b; |
181 | 179 | }), func_get_args()); |
182 | 180 | } |