@@ -8,7 +8,7 @@ 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 | 13 | }; |
| 14 | 14 | $arguments = func_get_args(); |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | function gt() |
| 20 | 20 | { |
| 21 | - $gt = function ($a, $b) { |
|
| 21 | + $gt = function($a, $b) { |
|
| 22 | 22 | return $a > $b; |
| 23 | 23 | }; |
| 24 | 24 | $arguments = func_get_args(); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | function gte() |
| 30 | 30 | { |
| 31 | - $gte = function ($a, $b) { |
|
| 31 | + $gte = function($a, $b) { |
|
| 32 | 32 | return $a >= $b; |
| 33 | 33 | }; |
| 34 | 34 | $arguments = func_get_args(); |
@@ -44,7 +44,7 @@ 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 | 49 | }; |
| 50 | 50 | $arguments = func_get_args(); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | function lt() |
| 56 | 56 | { |
| 57 | - $lt = function ($a, $b) { |
|
| 57 | + $lt = function($a, $b) { |
|
| 58 | 58 | return $a < $b; |
| 59 | 59 | }; |
| 60 | 60 | $arguments = func_get_args(); |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | function lte() |
| 66 | 66 | { |
| 67 | - $lte = function ($a, $b) { |
|
| 67 | + $lte = function($a, $b) { |
|
| 68 | 68 | return $a <= $b; |
| 69 | 69 | }; |
| 70 | 70 | $arguments = func_get_args(); |
@@ -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]; |
@@ -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 | } |
@@ -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 | |
@@ -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; |
@@ -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 = [ |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | public function testInsertNth() |
| 28 | 28 | { |
| 29 | 29 | $array = [1, 2, 3, 4, 5]; |
| 30 | - $expected = [1, 2, 'newItem', 3, 4, 5]; |
|
| 30 | + $expected = [1, 2, 'newItem', 3, 4, 5]; |
|
| 31 | 31 | $actual = insert(2)('newItem')($array); |
| 32 | 32 | $this->assertEquals($expected, $actual); |
| 33 | 33 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | function all() |
| 10 | 10 | { |
| 11 | - $all = function (callable $predicateFunction, array $array): bool { |
|
| 11 | + $all = function(callable $predicateFunction, array $array): bool { |
|
| 12 | 12 | if (empty($array)) { |
| 13 | 13 | return false; |
| 14 | 14 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | function any() |
| 33 | 33 | { |
| 34 | - $any = function (callable $predicateFunction, array $array) { |
|
| 34 | + $any = function(callable $predicateFunction, array $array) { |
|
| 35 | 35 | if (empty($array)) { |
| 36 | 36 | return false; |
| 37 | 37 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | function arrayForEach() |
| 56 | 56 | { |
| 57 | - $arrayForEach = function (callable $fn, array $array) { |
|
| 57 | + $arrayForEach = function(callable $fn, array $array) { |
|
| 58 | 58 | foreach ($array as $item) { |
| 59 | 59 | $fn($item); |
| 60 | 60 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | function append() |
| 74 | 74 | { |
| 75 | - $append = function ($item, array $array) { |
|
| 75 | + $append = function($item, array $array) { |
|
| 76 | 76 | return array_merge($array, [$item]); |
| 77 | 77 | }; |
| 78 | 78 | $arguments = func_get_args(); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | function concat() |
| 90 | 90 | { |
| 91 | - $concat = function (array $firstArray, array $secondArray) { |
|
| 91 | + $concat = function(array $firstArray, array $secondArray) { |
|
| 92 | 92 | return array_merge($firstArray, $secondArray); |
| 93 | 93 | }; |
| 94 | 94 | $arguments = func_get_args(); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | function drop() |
| 119 | 119 | { |
| 120 | - $drop = function (int $index, array $array) { |
|
| 120 | + $drop = function(int $index, array $array) { |
|
| 121 | 121 | return array_merge(array_slice($array, 0, $index), array_slice($array, $index + 1)); |
| 122 | 122 | }; |
| 123 | 123 | $arguments = func_get_args(); |
@@ -143,8 +143,8 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | function dropLast() |
| 145 | 145 | { |
| 146 | - $dropLast = function (array $array) { |
|
| 147 | - $index = count($array)-1; |
|
| 146 | + $dropLast = function(array $array) { |
|
| 147 | + $index = count($array) - 1; |
|
| 148 | 148 | return array_merge(array_slice($array, 0, $index), array_slice($array, $index + 1)); |
| 149 | 149 | }; |
| 150 | 150 | |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | function endsWith() |
| 162 | 162 | { |
| 163 | - $endsWith = function ($suffix, $list) { |
|
| 163 | + $endsWith = function($suffix, $list) { |
|
| 164 | 164 | if (is_string($suffix) && is_string($list)) { |
| 165 | 165 | return $suffix === '' || (($temp = strlen($list) - strlen($suffix)) >= 0 && strpos($list, $suffix) !== false); |
| 166 | 166 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | return true; |
| 176 | 176 | } |
| 177 | - throw new \InvalidArgumentException(__FUNCTION__ . 'accepts only string or array as it arguments'); |
|
| 177 | + throw new \InvalidArgumentException(__FUNCTION__.'accepts only string or array as it arguments'); |
|
| 178 | 178 | }; |
| 179 | 179 | $arguments = func_get_args(); |
| 180 | 180 | $curried = curryN($endsWith, 2); |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | function filter() |
| 190 | 190 | { |
| 191 | - $filter = function (callable $predicateFunction, array $array) { |
|
| 191 | + $filter = function(callable $predicateFunction, array $array) { |
|
| 192 | 192 | return array_values(array_filter($array, $predicateFunction)); |
| 193 | 193 | }; |
| 194 | 194 | $arguments = func_get_args(); |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | function filterPreserveKey() |
| 205 | 205 | { |
| 206 | - $filter = function (callable $predicateFunction, array $array) { |
|
| 206 | + $filter = function(callable $predicateFunction, array $array) { |
|
| 207 | 207 | return array_filter($array, $predicateFunction); |
| 208 | 208 | }; |
| 209 | 209 | $arguments = func_get_args(); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | function find() |
| 220 | 220 | { |
| 221 | - $find = function (callable $predicateFunction, array $list) { |
|
| 221 | + $find = function(callable $predicateFunction, array $list) { |
|
| 222 | 222 | foreach ($list as $item) { |
| 223 | 223 | if ($predicateFunction($item)) { |
| 224 | 224 | return $item; |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | function first() |
| 235 | 235 | { |
| 236 | - $first = function (array $array) { |
|
| 236 | + $first = function(array $array) { |
|
| 237 | 237 | if (empty($array)) { |
| 238 | 238 | return null; |
| 239 | 239 | } |
@@ -251,9 +251,9 @@ discard block |
||
| 251 | 251 | */ |
| 252 | 252 | function groupBy() |
| 253 | 253 | { |
| 254 | - $groupBy = function (callable $keySelector, array $array) { |
|
| 254 | + $groupBy = function(callable $keySelector, array $array) { |
|
| 255 | 255 | return reduce( |
| 256 | - function ($acc, $item) use ($keySelector) { |
|
| 256 | + function($acc, $item) use ($keySelector) { |
|
| 257 | 257 | $key = $keySelector($item); |
| 258 | 258 | $acc[$key] = array_key_exists($key, $acc) ? array_merge($acc[$key], [$item]) : [$item]; |
| 259 | 259 | return $acc; |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | |
| 270 | 270 | function head() |
| 271 | 271 | { |
| 272 | - $head = function (array $array) { |
|
| 272 | + $head = function(array $array) { |
|
| 273 | 273 | if (empty($array)) { |
| 274 | 274 | return null; |
| 275 | 275 | } |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | */ |
| 289 | 289 | function insert() |
| 290 | 290 | { |
| 291 | - $insert = function (int $index, $element, array $array) { |
|
| 291 | + $insert = function(int $index, $element, array $array) { |
|
| 292 | 292 | return array_merge( |
| 293 | 293 | array_slice($array, 0, $index), |
| 294 | 294 | [$element], |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | function last() |
| 304 | 304 | { |
| 305 | - $last = function (array $array) { |
|
| 305 | + $last = function(array $array) { |
|
| 306 | 306 | if (empty($array)) { |
| 307 | 307 | return null; |
| 308 | 308 | } |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | */ |
| 334 | 334 | function prepend() |
| 335 | 335 | { |
| 336 | - $prepend = function ($item, array $array) { |
|
| 336 | + $prepend = function($item, array $array) { |
|
| 337 | 337 | return array_merge([$item], $array); |
| 338 | 338 | }; |
| 339 | 339 | $arguments = func_get_args(); |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | */ |
| 350 | 350 | function reduce() |
| 351 | 351 | { |
| 352 | - $reduce = function (callable $accumulator, $initialValue, array $array) { |
|
| 352 | + $reduce = function(callable $accumulator, $initialValue, array $array) { |
|
| 353 | 353 | return array_reduce($array, $accumulator, $initialValue); |
| 354 | 354 | }; |
| 355 | 355 | $arguments = func_get_args(); |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | |
| 360 | 360 | function tail() |
| 361 | 361 | { |
| 362 | - $tail = function (array $array) { |
|
| 362 | + $tail = function(array $array) { |
|
| 363 | 363 | if (empty($array)) { |
| 364 | 364 | return null; |
| 365 | 365 | } |
@@ -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(); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | function orLogically() |
| 72 | 72 | { |
| 73 | - $and = function (bool $firstValue, bool $secondValue) { |
|
| 73 | + $and = function(bool $firstValue, bool $secondValue) { |
|
| 74 | 74 | return $firstValue || $secondValue; |
| 75 | 75 | }; |
| 76 | 76 | $arguments = func_get_args(); |