@@ -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 | } |
@@ -8,7 +8,7 @@ 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 | 13 | }; |
| 14 | 14 | $arguments = func_get_args(); |
@@ -18,7 +18,7 @@ discard block |
||
| 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 | 23 | }; |
| 24 | 24 | $arguments = func_get_args(); |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | function ifElse() |
| 37 | 37 | { |
| 38 | - $ifElse = function (callable $condition, callable $onTrue, callable $onFalse) { |
|
| 39 | - return function () use ($condition, $onTrue, $onFalse) { |
|
| 38 | + $ifElse = function(callable $condition, callable $onTrue, callable $onFalse) { |
|
| 39 | + return function() use ($condition, $onTrue, $onFalse) { |
|
| 40 | 40 | $arguments = func_get_args(); |
| 41 | 41 | if (call_user_func_array($condition, $arguments)) { |
| 42 | 42 | return call_user_func_array($onTrue, $arguments); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | function isEmpty() |
| 57 | 57 | { |
| 58 | - $isEmpty = function ($value) { |
|
| 58 | + $isEmpty = function($value) { |
|
| 59 | 59 | return empty($value); |
| 60 | 60 | }; |
| 61 | 61 | $arguments = func_get_args(); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | function not() |
| 71 | 71 | { |
| 72 | - $not = function ($value) { |
|
| 72 | + $not = function($value) { |
|
| 73 | 73 | return !$value; |
| 74 | 74 | }; |
| 75 | 75 | $arguments = func_get_args(); |
@@ -84,7 +84,7 @@ 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 | 89 | }; |
| 90 | 90 | $arguments = func_get_args(); |
@@ -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 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | function match() |
| 10 | 10 | { |
| 11 | - $match = function (string $pattern, string $string) { |
|
| 11 | + $match = function(string $pattern, string $string) { |
|
| 12 | 12 | preg_match($pattern, $string, $matches); |
| 13 | 13 | return $matches; |
| 14 | 14 | }; |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function replace() |
| 27 | 27 | { |
| 28 | - $replaceFn = function ($searchString, $replaceString, $subject) { |
|
| 28 | + $replaceFn = function($searchString, $replaceString, $subject) { |
|
| 29 | 29 | $searchString = '/'.preg_quote($searchString, '/').'/'; |
| 30 | 30 | return preg_replace($searchString, $replaceString, $subject, 1); |
| 31 | 31 | }; |
@@ -8,13 +8,13 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | function match() |
| 10 | 10 | { |
| 11 | - $match = function (string $pattern, string $string) { |
|
| 11 | + $match = function (string $pattern, string $string) { |
|
| 12 | 12 | preg_match($pattern, $string, $matches); |
| 13 | 13 | return $matches; |
| 14 | - }; |
|
| 15 | - $arguments = func_get_args(); |
|
| 16 | - $curried = curryN($match, 2); |
|
| 17 | - return call_user_func_array($curried, $arguments); |
|
| 14 | + }; |
|
| 15 | + $arguments = func_get_args(); |
|
| 16 | + $curried = curryN($match, 2); |
|
| 17 | + return call_user_func_array($curried, $arguments); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | /** |
@@ -25,14 +25,14 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function replace() |
| 27 | 27 | { |
| 28 | - $replaceFn = function ($searchString, $replaceString, $subject) { |
|
| 28 | + $replaceFn = function ($searchString, $replaceString, $subject) { |
|
| 29 | 29 | $searchString = '/'.preg_quote($searchString, '/').'/'; |
| 30 | 30 | return preg_replace($searchString, $replaceString, $subject, 1); |
| 31 | - }; |
|
| 31 | + }; |
|
| 32 | 32 | |
| 33 | - $arguments = func_get_args(); |
|
| 34 | - $curried = curryN($replaceFn, 3); |
|
| 35 | - return call_user_func_array($curried, $arguments); |
|
| 33 | + $arguments = func_get_args(); |
|
| 34 | + $curried = curryN($replaceFn, 3); |
|
| 35 | + return call_user_func_array($curried, $arguments); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | function replaceAll() |
| 45 | 45 | { |
| 46 | - $arguments = func_get_args(); |
|
| 47 | - $curried = curryN('str_replace', 3); |
|
| 48 | - return call_user_func_array($curried, $arguments); |
|
| 46 | + $arguments = func_get_args(); |
|
| 47 | + $curried = curryN('str_replace', 3); |
|
| 48 | + return call_user_func_array($curried, $arguments); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -56,15 +56,15 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | function replaceAllRegexp() |
| 58 | 58 | { |
| 59 | - $arguments = func_get_args(); |
|
| 60 | - $curried = curryN('preg_replace', 3); |
|
| 61 | - return call_user_func_array($curried, $arguments); |
|
| 59 | + $arguments = func_get_args(); |
|
| 60 | + $curried = curryN('preg_replace', 3); |
|
| 61 | + return call_user_func_array($curried, $arguments); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
| 65 | 65 | function toLower() |
| 66 | 66 | { |
| 67 | - $arguments = func_get_args(); |
|
| 68 | - $curried = curryN('strtolower', 1); |
|
| 69 | - return call_user_func_array($curried, $arguments); |
|
| 67 | + $arguments = func_get_args(); |
|
| 68 | + $curried = curryN('strtolower', 1); |
|
| 69 | + return call_user_func_array($curried, $arguments); |
|
| 70 | 70 | } |