-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add new functions * fix * remove codeclimate * codeclimate * codeclimate * modifications * fix * add test for object keys * change length of slice to null * Add ? * fix
- Loading branch information
Showing
18 changed files
with
465 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
engines: | ||
phpcodesniffer: | ||
enabled: true | ||
checks: | ||
Generic WhiteSpace ScopeIndent IncorrectExact: | ||
enabled: false | ||
phpmd: | ||
enabled: true | ||
checks: | ||
UnusedLocalVariable: | ||
enabled: false | ||
CleanCode/StaticAccess: | ||
enabled: false | ||
|
||
sonar-php: | ||
enabled: true | ||
checks: | ||
php:S1448: | ||
enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
use GW\Value\Wrap; | ||
|
||
$letters = Wrap::array(['a', 'b', 'c', 'd', 'e', 'f', 'g']); | ||
|
||
var_export($letters->skip(2)->toArray()); | ||
echo PHP_EOL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
use GW\Value\Wrap; | ||
|
||
$letters = Wrap::array(['a', 'b', 'c', 'd', 'e', 'f', 'g']); | ||
|
||
var_export($letters->skip(2)->take(4)->toArray()); | ||
echo PHP_EOL; | ||
|
||
var_export($letters->take(3)->toArray()); | ||
echo PHP_EOL; | ||
|
||
var_export($letters->take(100)->toArray()); | ||
echo PHP_EOL; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
use GW\Value\Wrap; | ||
|
||
$assoc = Wrap::assocArray(['0' => 'zero', '1' => 'one']); | ||
|
||
$keys = $assoc | ||
->map(fn(string $val, int $key): string => $val) | ||
->keys() | ||
->toArray(); | ||
|
||
var_dump($keys); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
use GW\Value\Wrap; | ||
|
||
$assoc = Wrap::iterable(['0' => 'zero', '1' => 'one']); | ||
|
||
$keys = $assoc | ||
->map(fn(string $val, int $key): string => $val) | ||
->keys() | ||
->toArray(); | ||
|
||
var_dump($keys); | ||
|
||
$pairs = [['0', 'zero'], ['1', 'one'], ['1', 'one one']]; | ||
|
||
$iterator = function () use ($pairs) { | ||
foreach ($pairs as [$key, $item]) { | ||
yield $key => $item; | ||
} | ||
}; | ||
|
||
$assoc = Wrap::iterable($iterator()); | ||
|
||
$keys = $assoc | ||
->map(fn(string $val, string $key): string => $val) | ||
->keys() | ||
->toArray(); | ||
|
||
var_dump($keys); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
use GW\Value\Wrap; | ||
|
||
$range = function (int $start, int $end): iterable { | ||
for ($i = $start; $i <= $end; $i++) { | ||
yield $i; | ||
} | ||
}; | ||
|
||
var_export(Wrap::iterable($range(0, PHP_INT_MAX))->skip(2)->take(4)->toArray()); | ||
echo PHP_EOL; | ||
|
||
var_export(Wrap::iterable($range(0, PHP_INT_MAX))->take(3)->toArray()); | ||
echo PHP_EOL; | ||
|
||
var_export(Wrap::iterable($range(0, PHP_INT_MAX))->skip(5000)->take(2)->toArray()); | ||
echo PHP_EOL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.