@@ -6,24 +6,24 @@ |
||
| 6 | 6 | |
| 7 | 7 | class FindTest extends TestCase |
| 8 | 8 | { |
| 9 | - public function testFindWithExistingValue() |
|
| 10 | - { |
|
| 9 | + public function testFindWithExistingValue() |
|
| 10 | + { |
|
| 11 | 11 | $isEqual3 = function ($it) { |
| 12 | - return 3 == $it; |
|
| 12 | + return 3 == $it; |
|
| 13 | 13 | }; |
| 14 | 14 | $list = [1, 2, 3, 4, 5]; |
| 15 | 15 | $expect = 3; |
| 16 | 16 | $actual = find($isEqual3)($list); |
| 17 | 17 | $this->assertEquals($expect, $actual); |
| 18 | - } |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - public function testFindWithNonExistingValue() |
|
| 21 | - { |
|
| 20 | + public function testFindWithNonExistingValue() |
|
| 21 | + { |
|
| 22 | 22 | $isEqual11 = function ($it) { |
| 23 | - return 11 == $it; |
|
| 23 | + return 11 == $it; |
|
| 24 | 24 | }; |
| 25 | 25 | $list = [1, 2, 3, 4, 5]; |
| 26 | 26 | $actual = find($isEqual11)($list); |
| 27 | 27 | $this->assertNull($actual); |
| 28 | - } |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 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 |
||
| 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]; |
@@ -6,55 +6,55 @@ |
||
| 6 | 6 | |
| 7 | 7 | class EndsWithTest extends TestCase |
| 8 | 8 | { |
| 9 | - public function testEndsWithValidString() |
|
| 10 | - { |
|
| 9 | + public function testEndsWithValidString() |
|
| 10 | + { |
|
| 11 | 11 | $suffix = 'SomeKeyword'; |
| 12 | 12 | $list = 'StringWhichEndsWithSomeKeyword'; |
| 13 | 13 | $actual = endsWith($suffix)($list); |
| 14 | 14 | $this->assertTrue($actual); |
| 15 | - } |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public function testEndsWithInvalidString() |
|
| 18 | - { |
|
| 17 | + public function testEndsWithInvalidString() |
|
| 18 | + { |
|
| 19 | 19 | $suffix = 'AnotherKeyword'; |
| 20 | 20 | $list = 'StringWhichEndsWithSomeKeyword'; |
| 21 | 21 | $actual = endsWith($suffix)($list); |
| 22 | 22 | $this->assertFalse($actual); |
| 23 | - } |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - public function testEndsWithEmptyString() |
|
| 26 | - { |
|
| 25 | + public function testEndsWithEmptyString() |
|
| 26 | + { |
|
| 27 | 27 | $suffix = ''; |
| 28 | 28 | $list = 'StringWhichEndsWithSomeKeyword'; |
| 29 | 29 | $actual = endsWith($suffix)($list); |
| 30 | 30 | $this->assertTrue($actual); |
| 31 | - } |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - public function testWithUnsupportedArguments() |
|
| 34 | - { |
|
| 33 | + public function testWithUnsupportedArguments() |
|
| 34 | + { |
|
| 35 | 35 | $this->expectException(\InvalidArgumentException::class); |
| 36 | 36 | endsWith(1)('111'); |
| 37 | - } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - public function testEndsWithEmptyArray() |
|
| 40 | - { |
|
| 39 | + public function testEndsWithEmptyArray() |
|
| 40 | + { |
|
| 41 | 41 | $suffix = []; |
| 42 | 42 | $list = [1, 2 ,3, 4]; |
| 43 | 43 | $actual = endsWith($suffix)($list); |
| 44 | 44 | $this->assertTrue($actual); |
| 45 | - } |
|
| 46 | - public function testEndsWithValidArray() |
|
| 47 | - { |
|
| 45 | + } |
|
| 46 | + public function testEndsWithValidArray() |
|
| 47 | + { |
|
| 48 | 48 | $suffix = [4]; |
| 49 | 49 | $list = [1, 2 ,3, 4]; |
| 50 | 50 | $actual = endsWith($suffix)($list); |
| 51 | 51 | $this->assertTrue($actual); |
| 52 | - } |
|
| 53 | - public function testEndsWithInvalidArray() |
|
| 54 | - { |
|
| 52 | + } |
|
| 53 | + public function testEndsWithInvalidArray() |
|
| 54 | + { |
|
| 55 | 55 | $suffix = [5]; |
| 56 | 56 | $list = [1, 2 ,3, 4]; |
| 57 | 57 | $actual = endsWith($suffix)($list); |
| 58 | 58 | $this->assertFalse($actual); |
| 59 | - } |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -39,21 +39,21 @@ |
||
| 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 | } |
@@ -7,16 +7,16 @@ |
||
| 7 | 7 | class ArrayForEachTest extends TestCase |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - public function testForEach() |
|
| 11 | - { |
|
| 10 | + public function testForEach() |
|
| 11 | + { |
|
| 12 | 12 | $list = [1, 2, 3]; |
| 13 | 13 | $mockFn = $this->createPartialMock(\stdClass::class, ['__invoke']); |
| 14 | 14 | $mockFn->expects($this->exactly(3)) |
| 15 | - ->method('__invoke') |
|
| 16 | - ->with($this->callback(function ($it) use ($list) { |
|
| 15 | + ->method('__invoke') |
|
| 16 | + ->with($this->callback(function ($it) use ($list) { |
|
| 17 | 17 | return in_array($it, $list); |
| 18 | - })); |
|
| 18 | + })); |
|
| 19 | 19 | |
| 20 | 20 | arrayForEach($mockFn)($list); |
| 21 | - } |
|
| 21 | + } |
|
| 22 | 22 | } |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | $mockFn = $this->createPartialMock(\stdClass::class, ['__invoke']); |
| 14 | 14 | $mockFn->expects($this->exactly(3)) |
| 15 | 15 | ->method('__invoke') |
| 16 | - ->with($this->callback(function ($it) use ($list) { |
|
| 16 | + ->with($this->callback(function($it) use ($list) { |
|
| 17 | 17 | return in_array($it, $list); |
| 18 | 18 | })); |
| 19 | 19 | |
@@ -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; |
@@ -6,16 +6,16 @@ |
||
| 6 | 6 | |
| 7 | 7 | class GroupByTest extends TestCase |
| 8 | 8 | { |
| 9 | - public function testGroupByIsEven() |
|
| 10 | - { |
|
| 9 | + public function testGroupByIsEven() |
|
| 10 | + { |
|
| 11 | 11 | $evenOrOdd = function ($value) { |
| 12 | - return $value % 2 === 0 ? 'even' : 'odd'; |
|
| 12 | + return $value % 2 === 0 ? 'even' : 'odd'; |
|
| 13 | 13 | }; |
| 14 | 14 | $expected = [ |
| 15 | - 'even' => [2, 4, 6], |
|
| 16 | - 'odd' => [1, 3, 5] |
|
| 15 | + 'even' => [2, 4, 6], |
|
| 16 | + 'odd' => [1, 3, 5] |
|
| 17 | 17 | ]; |
| 18 | 18 | $actual = groupBy($evenOrOdd)([1, 2, 3, 4, 5, 6]); |
| 19 | 19 | $this->assertEquals($expected, $actual); |
| 20 | - } |
|
| 20 | + } |
|
| 21 | 21 | } |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | { |
| 9 | 9 | public function testGroupByIsEven() |
| 10 | 10 | { |
| 11 | - $evenOrOdd = function ($value) { |
|
| 11 | + $evenOrOdd = function($value) { |
|
| 12 | 12 | return $value % 2 === 0 ? 'even' : 'odd'; |
| 13 | 13 | }; |
| 14 | 14 | $expected = [ |
@@ -7,15 +7,15 @@ |
||
| 7 | 7 | |
| 8 | 8 | class OrLogicallyTest extends TestCase |
| 9 | 9 | { |
| 10 | - public function testOrLogicallyWithTrueAndFalse() |
|
| 11 | - { |
|
| 10 | + public function testOrLogicallyWithTrueAndFalse() |
|
| 11 | + { |
|
| 12 | 12 | $actual = orLogically(true)(false); |
| 13 | 13 | $this->assertTrue($actual); |
| 14 | - } |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - public function testOrLogicallyWithFalseAndFalse() |
|
| 17 | - { |
|
| 16 | + public function testOrLogicallyWithFalseAndFalse() |
|
| 17 | + { |
|
| 18 | 18 | $actual = orLogically(false)(false); |
| 19 | 19 | $this->assertFalse($actual); |
| 20 | - } |
|
| 20 | + } |
|
| 21 | 21 | } |
@@ -6,15 +6,15 @@ |
||
| 6 | 6 | |
| 7 | 7 | class AndLogicallyTest extends TestCase |
| 8 | 8 | { |
| 9 | - public function testAndLogicallyWithTrueAndTrue() |
|
| 10 | - { |
|
| 9 | + public function testAndLogicallyWithTrueAndTrue() |
|
| 10 | + { |
|
| 11 | 11 | $actual = andLogically(true)(true); |
| 12 | 12 | $this->assertTrue($actual); |
| 13 | - } |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - public function testAndLogicallyWithTrueAndFalse() |
|
| 16 | - { |
|
| 15 | + public function testAndLogicallyWithTrueAndFalse() |
|
| 16 | + { |
|
| 17 | 17 | $actual = andLogically(true)(false); |
| 18 | 18 | $this->assertFalse($actual); |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -7,24 +7,24 @@ |
||
| 7 | 7 | |
| 8 | 8 | class IsEmptyTest extends TestCase |
| 9 | 9 | { |
| 10 | - public function testIsEmptyWithNull() |
|
| 11 | - { |
|
| 10 | + public function testIsEmptyWithNull() |
|
| 11 | + { |
|
| 12 | 12 | $actual = isEmpty()(null); |
| 13 | 13 | $this->assertTrue($actual); |
| 14 | - } |
|
| 15 | - public function testIsEmptyWithEmptyArray() |
|
| 16 | - { |
|
| 14 | + } |
|
| 15 | + public function testIsEmptyWithEmptyArray() |
|
| 16 | + { |
|
| 17 | 17 | $actual = isEmpty()([]); |
| 18 | 18 | $this->assertTrue($actual); |
| 19 | - } |
|
| 20 | - public function testIsEmptyWithNonEmptyArray() |
|
| 21 | - { |
|
| 19 | + } |
|
| 20 | + public function testIsEmptyWithNonEmptyArray() |
|
| 21 | + { |
|
| 22 | 22 | $actual = isEmpty()([1, 2, 3]); |
| 23 | 23 | $this->assertFalse($actual); |
| 24 | - } |
|
| 25 | - public function testIsEmptyWithStdClass() |
|
| 26 | - { |
|
| 24 | + } |
|
| 25 | + public function testIsEmptyWithStdClass() |
|
| 26 | + { |
|
| 27 | 27 | $actual = isEmpty()(new \stdClass()); |
| 28 | 28 | $this->assertFalse($actual); |
| 29 | - } |
|
| 29 | + } |
|
| 30 | 30 | } |