@@ -7,38 +7,38 @@ |
||
| 7 | 7 | |
| 8 | 8 | class NotTest extends TestCase |
| 9 | 9 | { |
| 10 | - public function testNotTrue() |
|
| 11 | - { |
|
| 10 | + public function testNotTrue() |
|
| 11 | + { |
|
| 12 | 12 | $value = true; |
| 13 | 13 | $actual = not()($value); |
| 14 | 14 | $this->assertFalse($actual); |
| 15 | - } |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public function testNotFalse() |
|
| 18 | - { |
|
| 17 | + public function testNotFalse() |
|
| 18 | + { |
|
| 19 | 19 | $value = false; |
| 20 | 20 | $actual = not()($value); |
| 21 | 21 | $this->assertTrue($actual); |
| 22 | - } |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - public function testNotNull() |
|
| 25 | - { |
|
| 24 | + public function testNotNull() |
|
| 25 | + { |
|
| 26 | 26 | $value = null; |
| 27 | 27 | $actual = not()($value); |
| 28 | 28 | $this->assertTrue($actual); |
| 29 | - } |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - public function testNotEmptyString() |
|
| 32 | - { |
|
| 31 | + public function testNotEmptyString() |
|
| 32 | + { |
|
| 33 | 33 | $value = ''; |
| 34 | 34 | $actual = not()($value); |
| 35 | 35 | $this->assertTrue($actual); |
| 36 | - } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - public function testNotObject() |
|
| 39 | - { |
|
| 38 | + public function testNotObject() |
|
| 39 | + { |
|
| 40 | 40 | $value = new \stdClass(); |
| 41 | 41 | $actual = not()($value); |
| 42 | 42 | $this->assertFalse($actual); |
| 43 | - } |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -8,22 +8,22 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | function andLogically() |
| 10 | 10 | { |
| 11 | - $and = function (bool $firstValue, bool $secondValue) { |
|
| 11 | + $and = function (bool $firstValue, bool $secondValue) { |
|
| 12 | 12 | return $firstValue && $secondValue; |
| 13 | - }; |
|
| 14 | - $arguments = func_get_args(); |
|
| 15 | - $curried = curryN($and, 2); |
|
| 16 | - return call_user_func_array($curried, $arguments); |
|
| 13 | + }; |
|
| 14 | + $arguments = func_get_args(); |
|
| 15 | + $curried = curryN($and, 2); |
|
| 16 | + return call_user_func_array($curried, $arguments); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | function defaultTo() |
| 20 | 20 | { |
| 21 | - $defaultTo = function ($defaultValue, $value) { |
|
| 21 | + $defaultTo = function ($defaultValue, $value) { |
|
| 22 | 22 | return $value ? $value : $defaultValue; |
| 23 | - }; |
|
| 24 | - $arguments = func_get_args(); |
|
| 25 | - $curried = curryN($defaultTo, 2); |
|
| 26 | - return call_user_func_array($curried, $arguments); |
|
| 23 | + }; |
|
| 24 | + $arguments = func_get_args(); |
|
| 25 | + $curried = curryN($defaultTo, 2); |
|
| 26 | + return call_user_func_array($curried, $arguments); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -35,18 +35,18 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | function ifElse() |
| 37 | 37 | { |
| 38 | - $ifElse = function (callable $condition, callable $onTrue, callable $onFalse) { |
|
| 38 | + $ifElse = function (callable $condition, callable $onTrue, callable $onFalse) { |
|
| 39 | 39 | return function () use ($condition, $onTrue, $onFalse) { |
| 40 | - $arguments = func_get_args(); |
|
| 41 | - if (call_user_func_array($condition, $arguments)) { |
|
| 40 | + $arguments = func_get_args(); |
|
| 41 | + if (call_user_func_array($condition, $arguments)) { |
|
| 42 | 42 | return call_user_func_array($onTrue, $arguments); |
| 43 | - } |
|
| 44 | - return call_user_func_array($onFalse, $arguments); |
|
| 43 | + } |
|
| 44 | + return call_user_func_array($onFalse, $arguments); |
|
| 45 | + }; |
|
| 45 | 46 | }; |
| 46 | - }; |
|
| 47 | - $arguments = func_get_args(); |
|
| 48 | - $curried = curryN($ifElse, 3); |
|
| 49 | - return call_user_func_array($curried, $arguments); |
|
| 47 | + $arguments = func_get_args(); |
|
| 48 | + $curried = curryN($ifElse, 3); |
|
| 49 | + return call_user_func_array($curried, $arguments); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | function isEmpty() |
| 57 | 57 | { |
| 58 | - $isEmpty = function ($value) { |
|
| 58 | + $isEmpty = function ($value) { |
|
| 59 | 59 | return empty($value); |
| 60 | - }; |
|
| 61 | - $arguments = func_get_args(); |
|
| 62 | - $curried = curryN($isEmpty, 1); |
|
| 63 | - return call_user_func_array($curried, $arguments); |
|
| 60 | + }; |
|
| 61 | + $arguments = func_get_args(); |
|
| 62 | + $curried = curryN($isEmpty, 1); |
|
| 63 | + return call_user_func_array($curried, $arguments); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -69,12 +69,12 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | function not() |
| 71 | 71 | { |
| 72 | - $not = function ($value) { |
|
| 72 | + $not = function ($value) { |
|
| 73 | 73 | return !$value; |
| 74 | - }; |
|
| 75 | - $arguments = func_get_args(); |
|
| 76 | - $curried = curryN($not, 1); |
|
| 77 | - return call_user_func_array($curried, $arguments); |
|
| 74 | + }; |
|
| 75 | + $arguments = func_get_args(); |
|
| 76 | + $curried = curryN($not, 1); |
|
| 77 | + return call_user_func_array($curried, $arguments); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -84,10 +84,10 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | function orLogically() |
| 86 | 86 | { |
| 87 | - $and = function (bool $firstValue, bool $secondValue) { |
|
| 87 | + $and = function (bool $firstValue, bool $secondValue) { |
|
| 88 | 88 | return $firstValue || $secondValue; |
| 89 | - }; |
|
| 90 | - $arguments = func_get_args(); |
|
| 91 | - $curried = curryN($and, 2); |
|
| 92 | - return call_user_func_array($curried, $arguments); |
|
| 89 | + }; |
|
| 90 | + $arguments = func_get_args(); |
|
| 91 | + $curried = curryN($and, 2); |
|
| 92 | + return call_user_func_array($curried, $arguments); |
|
| 93 | 93 | } |
@@ -7,40 +7,40 @@ |
||
| 7 | 7 | |
| 8 | 8 | class ReverseTest extends TestCase |
| 9 | 9 | { |
| 10 | - public function testReverseArray() |
|
| 11 | - { |
|
| 10 | + public function testReverseArray() |
|
| 11 | + { |
|
| 12 | 12 | $list = [1, 2, 3]; |
| 13 | 13 | $expect = [3, 2, 1]; |
| 14 | 14 | $actual = reverse()($list); |
| 15 | 15 | $this->assertEquals($expect, $actual); |
| 16 | - } |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - public function testReverseEmptyArray() |
|
| 19 | - { |
|
| 18 | + public function testReverseEmptyArray() |
|
| 19 | + { |
|
| 20 | 20 | $list = []; |
| 21 | 21 | $expect = []; |
| 22 | 22 | $actual = reverse()($list); |
| 23 | 23 | $this->assertEquals($expect, $actual); |
| 24 | - } |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - public function testReverseString() |
|
| 27 | - { |
|
| 26 | + public function testReverseString() |
|
| 27 | + { |
|
| 28 | 28 | $list = 'abc'; |
| 29 | 29 | $expect = 'cba'; |
| 30 | 30 | $actual = reverse()($list); |
| 31 | 31 | $this->assertEquals($expect, $actual); |
| 32 | - } |
|
| 33 | - public function testReverseEmptyString() |
|
| 34 | - { |
|
| 32 | + } |
|
| 33 | + public function testReverseEmptyString() |
|
| 34 | + { |
|
| 35 | 35 | $list = ''; |
| 36 | 36 | $expect = ''; |
| 37 | 37 | $actual = reverse()($list); |
| 38 | 38 | $this->assertEquals($expect, $actual); |
| 39 | - } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - public function testReverseUnsupportedType() |
|
| 42 | - { |
|
| 41 | + public function testReverseUnsupportedType() |
|
| 42 | + { |
|
| 43 | 43 | $this->expectException(\InvalidArgumentException::class); |
| 44 | 44 | reverse()(100); |
| 45 | - } |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -7,11 +7,11 @@ |
||
| 7 | 7 | |
| 8 | 8 | class FlattenTest extends TestCase |
| 9 | 9 | { |
| 10 | - public function testFlatten() |
|
| 11 | - { |
|
| 10 | + public function testFlatten() |
|
| 11 | + { |
|
| 12 | 12 | $array = [1, 2, [3, 4], [[5, 6, 7], [8, 9], 10]]; |
| 13 | 13 | $expect = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; |
| 14 | 14 | $actual = flatten()($array); |
| 15 | 15 | $this->assertEquals($expect, $actual); |
| 16 | - } |
|
| 16 | + } |
|
| 17 | 17 | } |
@@ -8,13 +8,13 @@ |
||
| 8 | 8 | |
| 9 | 9 | class ReplaceAllTest extends TestCase |
| 10 | 10 | { |
| 11 | - public function testReplace() |
|
| 12 | - { |
|
| 11 | + public function testReplace() |
|
| 12 | + { |
|
| 13 | 13 | $search = 'foo'; |
| 14 | 14 | $replace = 'bar'; |
| 15 | 15 | $subject = 'foo foo foo'; |
| 16 | 16 | $expect = 'bar bar bar'; |
| 17 | 17 | $actual = replaceAll($search)($replace)($subject); |
| 18 | 18 | $this->assertEquals($expect, $actual); |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -7,13 +7,13 @@ |
||
| 7 | 7 | |
| 8 | 8 | class ReplaceTest extends TestCase |
| 9 | 9 | { |
| 10 | - public function testReplace() |
|
| 11 | - { |
|
| 10 | + public function testReplace() |
|
| 11 | + { |
|
| 12 | 12 | $search = 'foo'; |
| 13 | 13 | $replace = 'bar'; |
| 14 | 14 | $subject = 'foo foo foo'; |
| 15 | 15 | $expect = 'bar foo foo'; |
| 16 | 16 | $actual = replace($search)($replace)($subject); |
| 17 | 17 | $this->assertEquals($expect, $actual); |
| 18 | - } |
|
| 18 | + } |
|
| 19 | 19 | } |
@@ -7,13 +7,13 @@ |
||
| 7 | 7 | |
| 8 | 8 | class ReplaceAllRegexpTest extends TestCase |
| 9 | 9 | { |
| 10 | - public function testReplace() |
|
| 11 | - { |
|
| 10 | + public function testReplace() |
|
| 11 | + { |
|
| 12 | 12 | $searchRegexp = '/[a-z]+/'; |
| 13 | 13 | $replace = 'bar'; |
| 14 | 14 | $subject = 'foo foo foo123'; |
| 15 | 15 | $expect = 'bar bar bar123'; |
| 16 | 16 | $actual = replaceAllRegexp($searchRegexp)($replace)($subject); |
| 17 | 17 | $this->assertEquals($expect, $actual); |
| 18 | - } |
|
| 18 | + } |
|
| 19 | 19 | } |
@@ -7,12 +7,12 @@ |
||
| 7 | 7 | |
| 8 | 8 | class RepeatTest extends TestCase |
| 9 | 9 | { |
| 10 | - public function testRepeat() |
|
| 11 | - { |
|
| 10 | + public function testRepeat() |
|
| 11 | + { |
|
| 12 | 12 | $item = 'hi'; |
| 13 | 13 | $count = 5; |
| 14 | 14 | $expect = ['hi', 'hi', 'hi', 'hi', 'hi']; |
| 15 | 15 | $actual = repeat($item)($count); |
| 16 | 16 | $this->assertEquals($expect, $actual); |
| 17 | - } |
|
| 17 | + } |
|
| 18 | 18 | } |
@@ -10,20 +10,20 @@ |
||
| 10 | 10 | |
| 11 | 11 | class SortByTest extends TestCase |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * @throws \Exception |
|
| 15 | - */ |
|
| 16 | - public function testSortBy() |
|
| 17 | - { |
|
| 13 | + /** |
|
| 14 | + * @throws \Exception |
|
| 15 | + */ |
|
| 16 | + public function testSortBy() |
|
| 17 | + { |
|
| 18 | 18 | $clara = ['name' => 'clara', 'age' => 314.159]; |
| 19 | 19 | $bob = ['name' => 'Bob', 'age' => -10]; |
| 20 | 20 | $alice = ['name' => 'ALICE', 'age' => 101]; |
| 21 | 21 | $sortByNameCaseInsensitive = sortBy(compose( |
| 22 | - 'strtolower', |
|
| 23 | - path(['name']) |
|
| 22 | + 'strtolower', |
|
| 23 | + path(['name']) |
|
| 24 | 24 | )); |
| 25 | 25 | $expect = [$alice, $bob, $clara]; |
| 26 | 26 | $actual = $sortByNameCaseInsensitive([$clara, $bob, $alice]); |
| 27 | 27 | $this->assertEquals($expect, $actual); |
| 28 | - } |
|
| 28 | + } |
|
| 29 | 29 | } |