@@ -7,19 +7,19 @@ |
||
| 7 | 7 | |
| 8 | 8 | class MedianTest extends TestCase |
| 9 | 9 | { |
| 10 | - public function testMedianWithOddNumberOfArguments() |
|
| 11 | - { |
|
| 10 | + public function testMedianWithOddNumberOfArguments() |
|
| 11 | + { |
|
| 12 | 12 | $numbers = [2, 9, 7]; |
| 13 | 13 | $expect = 7; |
| 14 | 14 | $actual = median()($numbers); |
| 15 | 15 | $this->assertEquals($expect, $actual); |
| 16 | - } |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - public function testMedianWithEvenNumberOfArguments() |
|
| 19 | - { |
|
| 18 | + public function testMedianWithEvenNumberOfArguments() |
|
| 19 | + { |
|
| 20 | 20 | $numbers = [7, 2, 10, 9]; |
| 21 | 21 | $expect = 8; |
| 22 | 22 | $actual = median()($numbers); |
| 23 | 23 | $this->assertEquals($expect, $actual); |
| 24 | - } |
|
| 24 | + } |
|
| 25 | 25 | } |
@@ -7,18 +7,18 @@ |
||
| 7 | 7 | |
| 8 | 8 | class MeanTest extends TestCase |
| 9 | 9 | { |
| 10 | - public function testMean() |
|
| 11 | - { |
|
| 10 | + public function testMean() |
|
| 11 | + { |
|
| 12 | 12 | $numbers = [2, 7, 9]; |
| 13 | 13 | $expect = 6; |
| 14 | 14 | $actual = mean()($numbers); |
| 15 | 15 | $this->assertEquals($expect, $actual); |
| 16 | - } |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - public function testMeanWithEmptyArray() |
|
| 19 | - { |
|
| 18 | + public function testMeanWithEmptyArray() |
|
| 19 | + { |
|
| 20 | 20 | $this->expectException(\InvalidArgumentException::class); |
| 21 | 21 | $numbers = []; |
| 22 | 22 | mean()($numbers); |
| 23 | - } |
|
| 23 | + } |
|
| 24 | 24 | } |
@@ -7,27 +7,27 @@ |
||
| 7 | 7 | |
| 8 | 8 | class ModuloTest extends TestCase |
| 9 | 9 | { |
| 10 | - public function testModuloEvenNumber() |
|
| 11 | - { |
|
| 10 | + public function testModuloEvenNumber() |
|
| 11 | + { |
|
| 12 | 12 | $number = 20; |
| 13 | 13 | $expect = 0; |
| 14 | 14 | $actual = modulo($number)(2); |
| 15 | 15 | $this->assertEquals($expect, $actual); |
| 16 | - } |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - public function testModuloOddNumber() |
|
| 19 | - { |
|
| 18 | + public function testModuloOddNumber() |
|
| 19 | + { |
|
| 20 | 20 | $number = 17; |
| 21 | 21 | $expect = 1; |
| 22 | 22 | $actual = modulo($number)(2); |
| 23 | 23 | $this->assertEquals($expect, $actual); |
| 24 | - } |
|
| 25 | - public function testCustomModulo() |
|
| 26 | - { |
|
| 24 | + } |
|
| 25 | + public function testCustomModulo() |
|
| 26 | + { |
|
| 27 | 27 | $number = 17; |
| 28 | 28 | $expect = 2; |
| 29 | 29 | $modBy = 5; |
| 30 | 30 | $actual = modulo($number)($modBy); |
| 31 | 31 | $this->assertEquals($expect, $actual); |
| 32 | - } |
|
| 32 | + } |
|
| 33 | 33 | } |
@@ -7,12 +7,12 @@ |
||
| 7 | 7 | |
| 8 | 8 | class MaxTest extends TestCase |
| 9 | 9 | { |
| 10 | - public function testMax() |
|
| 11 | - { |
|
| 10 | + public function testMax() |
|
| 11 | + { |
|
| 12 | 12 | $firstValue = 100; |
| 13 | 13 | $secondValue = 200; |
| 14 | 14 | $expect = 200; |
| 15 | 15 | $actual = max($firstValue)($secondValue); |
| 16 | 16 | $this->assertEquals($expect, $actual); |
| 17 | - } |
|
| 17 | + } |
|
| 18 | 18 | } |
@@ -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 | /** |
@@ -53,31 +53,31 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | function mean() |
| 55 | 55 | { |
| 56 | - $mean = function (array $numbers) { |
|
| 56 | + $mean = function (array $numbers) { |
|
| 57 | 57 | $length = count($numbers); |
| 58 | 58 | if ($length === 0) { |
| 59 | - throw new \InvalidArgumentException('$numbers passed to mean() must not be empty'); |
|
| 59 | + throw new \InvalidArgumentException('$numbers passed to mean() must not be empty'); |
|
| 60 | 60 | } |
| 61 | 61 | return array_sum($numbers)/$length; |
| 62 | - }; |
|
| 63 | - $arguments = func_get_args(); |
|
| 64 | - $curried = curryN($mean, 1); |
|
| 65 | - return call_user_func_array($curried, $arguments); |
|
| 62 | + }; |
|
| 63 | + $arguments = func_get_args(); |
|
| 64 | + $curried = curryN($mean, 1); |
|
| 65 | + return call_user_func_array($curried, $arguments); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | function median() |
| 69 | 69 | { |
| 70 | - $median = function (array $numbers) { |
|
| 70 | + $median = function (array $numbers) { |
|
| 71 | 71 | $length = count($numbers); |
| 72 | 72 | sort($numbers, SORT_NUMERIC); |
| 73 | 73 | if ($length % 2 == 0) { |
| 74 | - return mean([$numbers[$length/2], $numbers[$length/2 - 1]]); |
|
| 74 | + return mean([$numbers[$length/2], $numbers[$length/2 - 1]]); |
|
| 75 | 75 | } |
| 76 | 76 | return $numbers[($length-1)/2]; |
| 77 | - }; |
|
| 78 | - $arguments = func_get_args(); |
|
| 79 | - $curried = curryN($median, 1); |
|
| 80 | - return call_user_func_array($curried, $arguments); |
|
| 77 | + }; |
|
| 78 | + $arguments = func_get_args(); |
|
| 79 | + $curried = curryN($median, 1); |
|
| 80 | + return call_user_func_array($curried, $arguments); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -87,12 +87,12 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | function modulo() |
| 89 | 89 | { |
| 90 | - $modulo = function ($firstValue, $secondValue) { |
|
| 90 | + $modulo = function ($firstValue, $secondValue) { |
|
| 91 | 91 | return $firstValue % $secondValue; |
| 92 | - }; |
|
| 93 | - $arguments = func_get_args(); |
|
| 94 | - $curried = curryN($modulo, 2); |
|
| 95 | - return call_user_func_array($curried, $arguments); |
|
| 92 | + }; |
|
| 93 | + $arguments = func_get_args(); |
|
| 94 | + $curried = curryN($modulo, 2); |
|
| 95 | + return call_user_func_array($curried, $arguments); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | |
@@ -104,12 +104,12 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | function multiply() |
| 106 | 106 | { |
| 107 | - $multiply = function ($firstValue, $secondValue) { |
|
| 107 | + $multiply = function ($firstValue, $secondValue) { |
|
| 108 | 108 | return $firstValue * $secondValue; |
| 109 | - }; |
|
| 110 | - $arguments = func_get_args(); |
|
| 111 | - $curried = curryN($multiply, 2); |
|
| 112 | - return call_user_func_array($curried, $arguments); |
|
| 109 | + }; |
|
| 110 | + $arguments = func_get_args(); |
|
| 111 | + $curried = curryN($multiply, 2); |
|
| 112 | + return call_user_func_array($curried, $arguments); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -120,10 +120,10 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | function subtract() |
| 122 | 122 | { |
| 123 | - $subtract = function ($firstValue, $secondValue) { |
|
| 123 | + $subtract = function ($firstValue, $secondValue) { |
|
| 124 | 124 | return $firstValue - $secondValue; |
| 125 | - }; |
|
| 126 | - $arguments = func_get_args(); |
|
| 127 | - $curried = curryN($subtract, 2); |
|
| 128 | - return call_user_func_array($curried, $arguments); |
|
| 125 | + }; |
|
| 126 | + $arguments = func_get_args(); |
|
| 127 | + $curried = curryN($subtract, 2); |
|
| 128 | + return call_user_func_array($curried, $arguments); |
|
| 129 | 129 | } |
@@ -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(); |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | function mean() |
| 55 | 55 | { |
| 56 | - $mean = function (array $numbers) { |
|
| 56 | + $mean = function(array $numbers) { |
|
| 57 | 57 | $length = count($numbers); |
| 58 | 58 | if ($length === 0) { |
| 59 | 59 | throw new \InvalidArgumentException('$numbers passed to mean() must not be empty'); |
| 60 | 60 | } |
| 61 | - return array_sum($numbers)/$length; |
|
| 61 | + return array_sum($numbers) / $length; |
|
| 62 | 62 | }; |
| 63 | 63 | $arguments = func_get_args(); |
| 64 | 64 | $curried = curryN($mean, 1); |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | function median() |
| 69 | 69 | { |
| 70 | - $median = function (array $numbers) { |
|
| 70 | + $median = function(array $numbers) { |
|
| 71 | 71 | $length = count($numbers); |
| 72 | 72 | sort($numbers, SORT_NUMERIC); |
| 73 | 73 | if ($length % 2 == 0) { |
| 74 | - return mean([$numbers[$length/2], $numbers[$length/2 - 1]]); |
|
| 74 | + return mean([$numbers[$length / 2], $numbers[$length / 2 - 1]]); |
|
| 75 | 75 | } |
| 76 | - return $numbers[($length-1)/2]; |
|
| 76 | + return $numbers[($length - 1) / 2]; |
|
| 77 | 77 | }; |
| 78 | 78 | $arguments = func_get_args(); |
| 79 | 79 | $curried = curryN($median, 1); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | function modulo() |
| 89 | 89 | { |
| 90 | - $modulo = function ($firstValue, $secondValue) { |
|
| 90 | + $modulo = function($firstValue, $secondValue) { |
|
| 91 | 91 | return $firstValue % $secondValue; |
| 92 | 92 | }; |
| 93 | 93 | $arguments = func_get_args(); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | function multiply() |
| 106 | 106 | { |
| 107 | - $multiply = function ($firstValue, $secondValue) { |
|
| 107 | + $multiply = function($firstValue, $secondValue) { |
|
| 108 | 108 | return $firstValue * $secondValue; |
| 109 | 109 | }; |
| 110 | 110 | $arguments = func_get_args(); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | function subtract() |
| 122 | 122 | { |
| 123 | - $subtract = function ($firstValue, $secondValue) { |
|
| 123 | + $subtract = function($firstValue, $secondValue) { |
|
| 124 | 124 | return $firstValue - $secondValue; |
| 125 | 125 | }; |
| 126 | 126 | $arguments = func_get_args(); |
@@ -8,32 +8,32 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | function equals() |
| 10 | 10 | { |
| 11 | - $equals = function ($a, $b) { |
|
| 11 | + $equals = function ($a, $b) { |
|
| 12 | 12 | return $a == $b; |
| 13 | - }; |
|
| 14 | - $arguments = func_get_args(); |
|
| 15 | - $curried = curryN($equals, 2); |
|
| 16 | - return call_user_func_array($curried, $arguments); |
|
| 13 | + }; |
|
| 14 | + $arguments = func_get_args(); |
|
| 15 | + $curried = curryN($equals, 2); |
|
| 16 | + return call_user_func_array($curried, $arguments); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | function gt() |
| 20 | 20 | { |
| 21 | - $gt = function ($a, $b) { |
|
| 21 | + $gt = function ($a, $b) { |
|
| 22 | 22 | return $a > $b; |
| 23 | - }; |
|
| 24 | - $arguments = func_get_args(); |
|
| 25 | - $curried = curryN($gt, 2); |
|
| 26 | - return call_user_func_array($curried, $arguments); |
|
| 23 | + }; |
|
| 24 | + $arguments = func_get_args(); |
|
| 25 | + $curried = curryN($gt, 2); |
|
| 26 | + return call_user_func_array($curried, $arguments); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | function gte() |
| 30 | 30 | { |
| 31 | - $gte = function ($a, $b) { |
|
| 31 | + $gte = function ($a, $b) { |
|
| 32 | 32 | return $a >= $b; |
| 33 | - }; |
|
| 34 | - $arguments = func_get_args(); |
|
| 35 | - $curried = curryN($gte, 2); |
|
| 36 | - return call_user_func_array($curried, $arguments); |
|
| 33 | + }; |
|
| 34 | + $arguments = func_get_args(); |
|
| 35 | + $curried = curryN($gte, 2); |
|
| 36 | + return call_user_func_array($curried, $arguments); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -44,32 +44,32 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | function identical() |
| 46 | 46 | { |
| 47 | - $identical = function ($firstValue, $secondValue) { |
|
| 47 | + $identical = function ($firstValue, $secondValue) { |
|
| 48 | 48 | return $firstValue === $secondValue; |
| 49 | - }; |
|
| 50 | - $arguments = func_get_args(); |
|
| 51 | - $curried = curryN($identical, 2); |
|
| 52 | - return call_user_func_array($curried, $arguments); |
|
| 49 | + }; |
|
| 50 | + $arguments = func_get_args(); |
|
| 51 | + $curried = curryN($identical, 2); |
|
| 52 | + return call_user_func_array($curried, $arguments); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | function lt() |
| 56 | 56 | { |
| 57 | - $lt = function ($a, $b) { |
|
| 57 | + $lt = function ($a, $b) { |
|
| 58 | 58 | return $a < $b; |
| 59 | - }; |
|
| 60 | - $arguments = func_get_args(); |
|
| 61 | - $curried = curryN($lt, 2); |
|
| 62 | - return call_user_func_array($curried, $arguments); |
|
| 59 | + }; |
|
| 60 | + $arguments = func_get_args(); |
|
| 61 | + $curried = curryN($lt, 2); |
|
| 62 | + return call_user_func_array($curried, $arguments); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | function lte() |
| 66 | 66 | { |
| 67 | - $lte = function ($a, $b) { |
|
| 67 | + $lte = function ($a, $b) { |
|
| 68 | 68 | return $a <= $b; |
| 69 | - }; |
|
| 70 | - $arguments = func_get_args(); |
|
| 71 | - $curried = curryN($lte, 2); |
|
| 72 | - return call_user_func_array($curried, $arguments); |
|
| 69 | + }; |
|
| 70 | + $arguments = func_get_args(); |
|
| 71 | + $curried = curryN($lte, 2); |
|
| 72 | + return call_user_func_array($curried, $arguments); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | function max() |
| 81 | 81 | { |
| 82 | - $arguments = func_get_args(); |
|
| 83 | - $curried = curryN('max', 2); |
|
| 84 | - return call_user_func_array($curried, $arguments); |
|
| 82 | + $arguments = func_get_args(); |
|
| 83 | + $curried = curryN('max', 2); |
|
| 84 | + return call_user_func_array($curried, $arguments); |
|
| 85 | 85 | } |