Completed
Pull Request — master (#13)
by Siwapun
04:10
created
src/function.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
  */
8 8
 function always()
9 9
 {
10
-  $always = function ($data) {
11
-    return function () use ($data) {
10
+  $always = function($data) {
11
+    return function() use ($data) {
12 12
       return $data;
13 13
     };
14 14
   };
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  */
25 25
 function apply()
26 26
 {
27
-  $apply = function (callable $fn, array $args) {
27
+  $apply = function(callable $fn, array $args) {
28 28
     return call_user_func_array($fn, $args);
29 29
   };
30 30
   $arguments = func_get_args();
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
           return __FUNCTION__;
47 47
     case 1:
48 48
       $fn = $arguments[0];
49
-          return function (...$arguments) use ($fn) {
49
+          return function(...$arguments) use ($fn) {
50 50
             return call_user_func_array($fn, $arguments);
51 51
           };
52 52
     default:
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
  */
73 73
 function construct()
74 74
 {
75
-  $construct = function ($class) {
76
-    return function () use ($class) {
75
+  $construct = function($class) {
76
+    return function() use ($class) {
77 77
       return new $class();
78 78
     };
79 79
   };
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
 function curryN(callable $fn, int $numberOfArguments)
86 86
 {
87
-  return function () use ($fn, $numberOfArguments) {
87
+  return function() use ($fn, $numberOfArguments) {
88 88
     $arguments = func_get_args();
89 89
     $length = count($arguments);
90 90
     if ($length > $numberOfArguments) {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
       return call_user_func_array($fn, $arguments);
98 98
     }
99 99
     // AUTO CURRY
100
-    $curriedFn = function () use ($fn, $arguments) {
100
+    $curriedFn = function() use ($fn, $arguments) {
101 101
       $curriedArguments = func_get_args();
102 102
       return call_user_func_array($fn, array_merge($arguments, $curriedArguments));
103 103
     };
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
  */
112 112
 function identity()
113 113
 {
114
-  $identity = function ($value) {
114
+  $identity = function($value) {
115 115
     return $value;
116 116
   };
117 117
   $arguments = func_get_args();
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
  */
128 128
 function partial(callable $fn, array $args)
129 129
 {
130
-  return function () use ($fn, $args) {
130
+  return function() use ($fn, $args) {
131 131
     $arguments = func_get_args();
132 132
     return call_user_func_array($fn, array_merge($args, $arguments));
133 133
   };
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
  */
142 142
 function partialRight(callable $fn, array $args)
143 143
 {
144
-  return function () use ($fn, $args) {
144
+  return function() use ($fn, $args) {
145 145
     $arguments = func_get_args();
146 146
     return call_user_func_array($fn, array_merge($arguments, $args));
147 147
   };
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
   if ($length === 0) {
159 159
     throw new \Exception("pipe requires at least one argument");
160 160
   }
161
-  return function () use ($arguments) {
161
+  return function() use ($arguments) {
162 162
     $internalArguments = func_get_args();
163 163
     $initialValue = call_user_func_array($arguments[0], $internalArguments);
164
-    $accumulator = function ($acc, $it) {
164
+    $accumulator = function($acc, $it) {
165 165
       return call_user_func_array($it, [$acc]);
166 166
     };
167 167
     return array_reduce(drop(0, $arguments), $accumulator, $initialValue);
Please login to merge, or discard this patch.
src/relation.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 function equals()
10 10
 {
11
-  $equals = function ($a, $b) {
11
+  $equals = function($a, $b) {
12 12
     return $a == $b;
13 13
   };
14 14
   $arguments = func_get_args();
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
 function gt()
20 20
 {
21
-  $gt = function ($a, $b) {
21
+  $gt = function($a, $b) {
22 22
     return $a > $b;
23 23
   };
24 24
   $arguments = func_get_args();
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
 function gte()
30 30
 {
31
-  $gte = function ($a, $b) {
31
+  $gte = function($a, $b) {
32 32
     return $a >= $b;
33 33
   };
34 34
   $arguments = func_get_args();
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
  */
45 45
 function identical()
46 46
 {
47
-  $identical = function ($firstValue, $secondValue) {
47
+  $identical = function($firstValue, $secondValue) {
48 48
     return $firstValue === $secondValue;
49 49
   };
50 50
   $arguments = func_get_args();
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
 function lt()
56 56
 {
57
-  $lt = function ($a, $b) {
57
+  $lt = function($a, $b) {
58 58
     return $a < $b;
59 59
   };
60 60
   $arguments = func_get_args();
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 
65 65
 function lte()
66 66
 {
67
-  $lte = function ($a, $b) {
67
+  $lte = function($a, $b) {
68 68
     return $a <= $b;
69 69
   };
70 70
   $arguments = func_get_args();
Please login to merge, or discard this patch.
test/FindTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 {
9 9
   public function testFindWithExistingValue()
10 10
   {
11
-    $isEqual3 = function ($it) {
11
+    $isEqual3 = function($it) {
12 12
       return 3 == $it;
13 13
     };
14 14
     $list = [1, 2, 3, 4, 5];
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 
20 20
   public function testFindWithNonExistingValue()
21 21
   {
22
-    $isEqual11 = function ($it) {
22
+    $isEqual11 = function($it) {
23 23
       return 11 == $it;
24 24
     };
25 25
     $list = [1, 2, 3, 4, 5];
Please login to merge, or discard this patch.
test/EndsWithTest.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,21 +39,21 @@
 block discarded – undo
39 39
   public function testEndsWithEmptyArray()
40 40
   {
41 41
     $suffix = [];
42
-    $list = [1, 2 ,3, 4];
42
+    $list = [1, 2, 3, 4];
43 43
     $actual = endsWith($suffix)($list);
44 44
     $this->assertTrue($actual);
45 45
   }
46 46
   public function testEndsWithValidArray()
47 47
   {
48 48
     $suffix = [4];
49
-    $list = [1, 2 ,3, 4];
49
+    $list = [1, 2, 3, 4];
50 50
     $actual = endsWith($suffix)($list);
51 51
     $this->assertTrue($actual);
52 52
   }
53 53
   public function testEndsWithInvalidArray()
54 54
   {
55 55
     $suffix = [5];
56
-    $list = [1, 2 ,3, 4];
56
+    $list = [1, 2, 3, 4];
57 57
     $actual = endsWith($suffix)($list);
58 58
     $this->assertFalse($actual);
59 59
   }
Please login to merge, or discard this patch.
src/list.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 function all()
10 10
 {
11
-  $all = function (callable $predicateFunction, array $array): bool {
11
+  $all = function(callable $predicateFunction, array $array): bool {
12 12
     if (empty($array)) {
13 13
       return false;
14 14
     }
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  */
32 32
 function any()
33 33
 {
34
-  $any = function (callable $predicateFunction, array $array) {
34
+  $any = function(callable $predicateFunction, array $array) {
35 35
     if (empty($array)) {
36 36
       return false;
37 37
     }
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
  */
56 56
 function append()
57 57
 {
58
-  $append = function ($item, array $array) {
58
+  $append = function($item, array $array) {
59 59
     return array_merge($array, [$item]);
60 60
   };
61 61
   $arguments = func_get_args();
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
  */
72 72
 function concat()
73 73
 {
74
-  $concat = function (array $firstArray, array $secondArray) {
74
+  $concat = function(array $firstArray, array $secondArray) {
75 75
     return array_merge($firstArray, $secondArray);
76 76
   };
77 77
   $arguments = func_get_args();
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
  */
101 101
 function drop()
102 102
 {
103
-  $drop = function (int $index, array $array) {
103
+  $drop = function(int $index, array $array) {
104 104
     return array_merge(array_slice($array, 0, $index), array_slice($array, $index + 1));
105 105
   };
106 106
   $arguments = func_get_args();
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
  */
127 127
 function dropLast()
128 128
 {
129
-  $dropLast = function (array $array) {
130
-    $index = count($array)-1;
129
+  $dropLast = function(array $array) {
130
+    $index = count($array) - 1;
131 131
     return array_merge(array_slice($array, 0, $index), array_slice($array, $index + 1));
132 132
   };
133 133
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
  */
144 144
 function endsWith()
145 145
 {
146
-  $endsWith = function ($suffix, $list) {
146
+  $endsWith = function($suffix, $list) {
147 147
     if (is_string($suffix) && is_string($list)) {
148 148
       return $suffix === '' || (($temp = strlen($list) - strlen($suffix)) >= 0 && strpos($list, $suffix) !== false);
149 149
     }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
       }
158 158
       return true;
159 159
     }
160
-    throw new \InvalidArgumentException(__FUNCTION__ . 'accepts only string or array as it arguments');
160
+    throw new \InvalidArgumentException(__FUNCTION__.'accepts only string or array as it arguments');
161 161
   };
162 162
   $arguments = func_get_args();
163 163
   $curried = curryN($endsWith, 2);
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
  */
172 172
 function filter()
173 173
 {
174
-  $filter = function (callable $predicateFunction, array $array) {
174
+  $filter = function(callable $predicateFunction, array $array) {
175 175
      return array_values(array_filter($array, $predicateFunction));
176 176
   };
177 177
   $arguments = func_get_args();
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
  */
187 187
 function filterPreserveKey()
188 188
 {
189
-  $filter = function (callable $predicateFunction, array $array) {
189
+  $filter = function(callable $predicateFunction, array $array) {
190 190
     return array_filter($array, $predicateFunction);
191 191
   };
192 192
   $arguments = func_get_args();
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
  */
202 202
 function find()
203 203
 {
204
-  $find = function (callable $predicateFunction, array $list) {
204
+  $find = function(callable $predicateFunction, array $list) {
205 205
     foreach ($list as $item) {
206 206
       if ($predicateFunction($item)) {
207 207
         return $item;
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 
217 217
 function first()
218 218
 {
219
-  $first = function (array $array) {
219
+  $first = function(array $array) {
220 220
     if (empty($array)) {
221 221
       return null;
222 222
     }
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 
230 230
 function head()
231 231
 {
232
-  $head = function (array $array) {
232
+  $head = function(array $array) {
233 233
     if (empty($array)) {
234 234
       return null;
235 235
     }
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 
243 243
 function last()
244 244
 {
245
-  $last = function (array $array) {
245
+  $last = function(array $array) {
246 246
     if (empty($array)) {
247 247
       return null;
248 248
     }
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
  */
274 274
 function prepend()
275 275
 {
276
-  $prepend = function ($item, array $array) {
276
+  $prepend = function($item, array $array) {
277 277
     return array_merge([$item], $array);
278 278
   };
279 279
   $arguments = func_get_args();
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
  */
290 290
 function reduce()
291 291
 {
292
-  $reduce = function (callable $accumulator, $initialValue, array $array) {
292
+  $reduce = function(callable $accumulator, $initialValue, array $array) {
293 293
     return array_reduce($array, $accumulator, $initialValue);
294 294
   };
295 295
   $arguments = func_get_args();
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 
300 300
 function tail()
301 301
 {
302
-  $tail = function (array $array) {
302
+  $tail = function(array $array) {
303 303
     if (empty($array)) {
304 304
       return null;
305 305
     }
Please login to merge, or discard this patch.
test/IfElseTest.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@  discard block
 block discarded – undo
9 9
   public function testIfElseOnTrueCondition()
10 10
   {
11 11
     $value = 10;
12
-    $isEven = function ($it) {
12
+    $isEven = function($it) {
13 13
       return $it % 2 === 0;
14 14
     };
15
-    $powerTwo = function ($it) {
15
+    $powerTwo = function($it) {
16 16
       return $it * $it;
17 17
     };
18
-    $powerThree = function ($it) {
18
+    $powerThree = function($it) {
19 19
       return $it * $it * $it;
20 20
     };
21 21
     $expect = 100;
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
   public function testIfElseOnFalseCondition()
27 27
   {
28 28
     $value = 10;
29
-    $isOdd = function ($it) {
29
+    $isOdd = function($it) {
30 30
       return $it % 2 !== 0;
31 31
     };
32
-    $powerTwo = function ($it) {
32
+    $powerTwo = function($it) {
33 33
       return $it * $it;
34 34
     };
35
-    $powerThree = function ($it) {
35
+    $powerThree = function($it) {
36 36
       return $it * $it * $it;
37 37
     };
38 38
     $expect = 1000;
Please login to merge, or discard this patch.
src/math.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 function add()
11 11
 {
12
-  $add = function ($firstValue, $secondValue) {
12
+  $add = function($firstValue, $secondValue) {
13 13
     return $firstValue + $secondValue;
14 14
   };
15 15
   $arguments = func_get_args();
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function divide()
27 27
 {
28
-  $divide = function ($firstValue, $secondValue) {
28
+  $divide = function($firstValue, $secondValue) {
29 29
     return $firstValue / $secondValue;
30 30
   };
31 31
   $arguments = func_get_args();
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  */
40 40
 function inc()
41 41
 {
42
-  $inc = function ($value) {
42
+  $inc = function($value) {
43 43
     return $value + 1;
44 44
   };
45 45
   $arguments = func_get_args();
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
  */
56 56
 function multiply()
57 57
 {
58
-  $multiply = function ($firstValue, $secondValue) {
58
+  $multiply = function($firstValue, $secondValue) {
59 59
     return $firstValue * $secondValue;
60 60
   };
61 61
   $arguments = func_get_args();
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
  */
72 72
 function subtract()
73 73
 {
74
-  $subtract = function ($firstValue, $secondValue) {
74
+  $subtract = function($firstValue, $secondValue) {
75 75
     return $firstValue - $secondValue;
76 76
   };
77 77
   $arguments = func_get_args();
Please login to merge, or discard this patch.
src/logic.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 
4 4
 function defaultTo()
5 5
 {
6
-  $defaultTo = function ($defaultValue, $value) {
6
+  $defaultTo = function($defaultValue, $value) {
7 7
     return $value ? $value : $defaultValue;
8 8
   };
9 9
   $arguments = func_get_args();
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function ifElse()
22 22
 {
23
-  $ifElse = function (callable $condition, callable $onTrue, callable $onFalse) {
24
-    return function () use ($condition, $onTrue, $onFalse) {
23
+  $ifElse = function(callable $condition, callable $onTrue, callable $onFalse) {
24
+    return function() use ($condition, $onTrue, $onFalse) {
25 25
       $arguments = func_get_args();
26 26
       if (call_user_func_array($condition, $arguments)) {
27 27
         return call_user_func_array($onTrue, $arguments);
Please login to merge, or discard this patch.