Completed
Push — master ( 5e2d42...f80c85 )
by Amine
02:13
created
src/list.php 1 patch
Spacing   +17 added lines, -18 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             : '';
@@ -322,8 +322,7 @@  discard block
 block discarded – undo
322 322
  */
323 323
 function concatAll() {
324 324
     $concatAll = function($lists) {
325
-        return length($lists) == 0 ? [] :
326
-            reduce(concat(), head($lists), tail($lists));
325
+        return length($lists) == 0 ? [] : reduce(concat(), head($lists), tail($lists));
327 326
     };
328 327
     return apply(curry($concatAll), func_get_args());
329 328
 }
@@ -402,7 +401,7 @@  discard block
 block discarded – undo
402 401
  * @return array
403 402
  */
404 403
 function append() {
405
-    $append = function ($item, $list) {
404
+    $append = function($item, $list) {
406 405
         return insert(length($list), $item, $list);
407 406
     };
408 407
     return apply(curry($append), func_get_args());
@@ -449,7 +448,7 @@  discard block
 block discarded – undo
449 448
         $length = length($list);
450 449
         if ($count > $length || $count < -$length)
451 450
             return [];
452
-        if(is_string($list)) {
451
+        if (is_string($list)) {
453 452
             return ($count >= 0)
454 453
                 ? substr($list, 0, $count)
455 454
                 : substr($list, $count);
@@ -705,9 +704,9 @@  discard block
 block discarded – undo
705 704
  */
706 705
 function slices() {
707 706
     $slices = function($size, $list) {
708
-        if(empty($list))
707
+        if (empty($list))
709 708
             return is_string($list) ? '' : [];
710
-        if(length($list) <= $size)
709
+        if (length($list) <= $size)
711 710
             return [$list];
712 711
         return prepend(take($size, $list), slices($size, remove($size, $list)));
713 712
     };
@@ -731,7 +730,7 @@  discard block
 block discarded – undo
731 730
  */
732 731
 function contains() {
733 732
     $contains = function($item, $list) {
734
-        return -1 != indexOf($item, $list);
733
+        return - 1 != indexOf($item, $list);
735 734
     };
736 735
     return apply(curry($contains), func_get_args());
737 736
 }
@@ -780,7 +779,7 @@  discard block
 block discarded – undo
780 779
 function findLastIndex() {
781 780
     $findLastIndex = function($predicate, $list) {
782 781
         foreach (reverse(toPairs($list)) as $pair) {
783
-            if($predicate($pair[1]))
782
+            if ($predicate($pair[1]))
784 783
                 return $pair[0];
785 784
         }
786 785
         return null;
@@ -857,7 +856,7 @@  discard block
 block discarded – undo
857 856
             $index = findIndex(equals($item), $list);
858 857
         }
859 858
         return (false === $index || null === $index)
860
-            ? -1
859
+            ? - 1
861 860
             : $index;
862 861
     };
863 862
     return apply(curry($indexOf), func_get_args());
@@ -887,7 +886,7 @@  discard block
 block discarded – undo
887 886
             $index = findLastIndex(equals($item), $list);
888 887
         }
889 888
         return (false === $index || null === $index)
890
-            ? -1
889
+            ? - 1
891 890
             : $index;
892 891
     };
893 892
     return apply(curry($lastIndexOf), func_get_args());
@@ -972,7 +971,7 @@  discard block
 block discarded – undo
972 971
     $groupBy = function($fn, $list) {
973 972
         return reduce(function($result, $item) use($fn) {
974 973
             $index = $fn($item);
975
-            if (! isset($result[$index]))
974
+            if (!isset($result[$index]))
976 975
                 $result[$index] = [];
977 976
             $result[$index][] = $item;
978 977
             return $result;
Please login to merge, or discard this patch.