@@ -6,11 +6,11 @@ |
||
6 | 6 | |
7 | 7 | class IncTest extends TestCase |
8 | 8 | { |
9 | - public function testInc() |
|
10 | - { |
|
9 | + public function testInc() |
|
10 | + { |
|
11 | 11 | $value = 10; |
12 | 12 | $expect = 11; |
13 | 13 | $actual = inc()(10); |
14 | 14 | $this->assertEquals($expect, $actual); |
15 | - } |
|
15 | + } |
|
16 | 16 | } |
@@ -6,37 +6,37 @@ |
||
6 | 6 | |
7 | 7 | class IfElseTest extends TestCase |
8 | 8 | { |
9 | - public function testIfElseOnTrueCondition() |
|
10 | - { |
|
9 | + public function testIfElseOnTrueCondition() |
|
10 | + { |
|
11 | 11 | $value = 10; |
12 | 12 | $isEven = function ($it) { |
13 | - return $it % 2 === 0; |
|
13 | + return $it % 2 === 0; |
|
14 | 14 | }; |
15 | 15 | $powerTwo = function ($it) { |
16 | - return $it * $it; |
|
16 | + return $it * $it; |
|
17 | 17 | }; |
18 | 18 | $powerThree = function ($it) { |
19 | - return $it * $it * $it; |
|
19 | + return $it * $it * $it; |
|
20 | 20 | }; |
21 | 21 | $expect = 100; |
22 | 22 | $actual = ifElse($isEven)($powerTwo)($powerThree)($value); |
23 | 23 | $this->assertEquals($expect, $actual); |
24 | - } |
|
24 | + } |
|
25 | 25 | |
26 | - public function testIfElseOnFalseCondition() |
|
27 | - { |
|
26 | + public function testIfElseOnFalseCondition() |
|
27 | + { |
|
28 | 28 | $value = 10; |
29 | 29 | $isOdd = function ($it) { |
30 | - return $it % 2 !== 0; |
|
30 | + return $it % 2 !== 0; |
|
31 | 31 | }; |
32 | 32 | $powerTwo = function ($it) { |
33 | - return $it * $it; |
|
33 | + return $it * $it; |
|
34 | 34 | }; |
35 | 35 | $powerThree = function ($it) { |
36 | - return $it * $it * $it; |
|
36 | + return $it * $it * $it; |
|
37 | 37 | }; |
38 | 38 | $expect = 1000; |
39 | 39 | $actual = ifElse($isOdd)($powerTwo)($powerThree)($value); |
40 | 40 | $this->assertEquals($expect, $actual); |
41 | - } |
|
41 | + } |
|
42 | 42 | } |
@@ -9,13 +9,13 @@ discard block |
||
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 |
||
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; |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | */ |
10 | 10 | function add() |
11 | 11 | { |
12 | - $add = function ($firstValue, $secondValue) { |
|
12 | + $add = function ($firstValue, $secondValue) { |
|
13 | 13 | return $firstValue + $secondValue; |
14 | - }; |
|
15 | - $arguments = func_get_args(); |
|
16 | - $curried = curryN($add, 2); |
|
17 | - return call_user_func_array($curried, $arguments); |
|
14 | + }; |
|
15 | + $arguments = func_get_args(); |
|
16 | + $curried = curryN($add, 2); |
|
17 | + return call_user_func_array($curried, $arguments); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function divide() |
27 | 27 | { |
28 | - $divide = function ($firstValue, $secondValue) { |
|
28 | + $divide = function ($firstValue, $secondValue) { |
|
29 | 29 | return $firstValue / $secondValue; |
30 | - }; |
|
31 | - $arguments = func_get_args(); |
|
32 | - $curried = curryN($divide, 2); |
|
33 | - return call_user_func_array($curried, $arguments); |
|
30 | + }; |
|
31 | + $arguments = func_get_args(); |
|
32 | + $curried = curryN($divide, 2); |
|
33 | + return call_user_func_array($curried, $arguments); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function inc() |
41 | 41 | { |
42 | - $inc = function ($value) { |
|
42 | + $inc = function ($value) { |
|
43 | 43 | return $value + 1; |
44 | - }; |
|
45 | - $arguments = func_get_args(); |
|
46 | - $curried = curryN($inc, 1); |
|
47 | - return call_user_func_array($curried, $arguments); |
|
44 | + }; |
|
45 | + $arguments = func_get_args(); |
|
46 | + $curried = curryN($inc, 1); |
|
47 | + return call_user_func_array($curried, $arguments); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | */ |
56 | 56 | function multiply() |
57 | 57 | { |
58 | - $multiply = function ($firstValue, $secondValue) { |
|
58 | + $multiply = function ($firstValue, $secondValue) { |
|
59 | 59 | return $firstValue * $secondValue; |
60 | - }; |
|
61 | - $arguments = func_get_args(); |
|
62 | - $curried = curryN($multiply, 2); |
|
63 | - return call_user_func_array($curried, $arguments); |
|
60 | + }; |
|
61 | + $arguments = func_get_args(); |
|
62 | + $curried = curryN($multiply, 2); |
|
63 | + return call_user_func_array($curried, $arguments); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | */ |
72 | 72 | function subtract() |
73 | 73 | { |
74 | - $subtract = function ($firstValue, $secondValue) { |
|
74 | + $subtract = function ($firstValue, $secondValue) { |
|
75 | 75 | return $firstValue - $secondValue; |
76 | - }; |
|
77 | - $arguments = func_get_args(); |
|
78 | - $curried = curryN($subtract, 2); |
|
79 | - return call_user_func_array($curried, $arguments); |
|
76 | + }; |
|
77 | + $arguments = func_get_args(); |
|
78 | + $curried = curryN($subtract, 2); |
|
79 | + return call_user_func_array($curried, $arguments); |
|
80 | 80 | } |
@@ -9,7 +9,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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(); |
@@ -3,12 +3,12 @@ discard block |
||
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 | - }; |
|
9 | - $arguments = func_get_args(); |
|
10 | - $curried = curryN($defaultTo, 2); |
|
11 | - return call_user_func_array($curried, $arguments); |
|
8 | + }; |
|
9 | + $arguments = func_get_args(); |
|
10 | + $curried = curryN($defaultTo, 2); |
|
11 | + return call_user_func_array($curried, $arguments); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -20,16 +20,16 @@ discard block |
||
20 | 20 | */ |
21 | 21 | function ifElse() |
22 | 22 | { |
23 | - $ifElse = function (callable $condition, callable $onTrue, callable $onFalse) { |
|
23 | + $ifElse = function (callable $condition, callable $onTrue, callable $onFalse) { |
|
24 | 24 | return function () use ($condition, $onTrue, $onFalse) { |
25 | - $arguments = func_get_args(); |
|
26 | - if (call_user_func_array($condition, $arguments)) { |
|
25 | + $arguments = func_get_args(); |
|
26 | + if (call_user_func_array($condition, $arguments)) { |
|
27 | 27 | return call_user_func_array($onTrue, $arguments); |
28 | - } |
|
29 | - return call_user_func_array($onFalse, $arguments); |
|
28 | + } |
|
29 | + return call_user_func_array($onFalse, $arguments); |
|
30 | + }; |
|
30 | 31 | }; |
31 | - }; |
|
32 | - $arguments = func_get_args(); |
|
33 | - $curried = curryN($ifElse, 3); |
|
34 | - return call_user_func_array($curried, $arguments); |
|
32 | + $arguments = func_get_args(); |
|
33 | + $curried = curryN($ifElse, 3); |
|
34 | + return call_user_func_array($curried, $arguments); |
|
35 | 35 | } |
@@ -3,7 +3,7 @@ discard block |
||
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 |
||
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); |