Skip to content

Commit

Permalink
Add IterableValue examples (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
bronek89 authored Jan 7, 2019
1 parent 0316364 commit c492612
Show file tree
Hide file tree
Showing 12 changed files with 670 additions and 1 deletion.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,35 @@ $stringsArray = Wrap::stringsArray(['one', ' two ', '<b>three</b>'])
});
```

### `IterableValue`

Object wrapping iterable.

```php
<?php

use \GW\Value\Wrap;

$range = function (int $start, int $end) {
for ($i = $start; $i <= $end; $i++) {
yield $i;
}
};

$stringsArray = Wrap::iterable($range(0, 10))
->join(Wrap::iterable($range(400, 440000)))
->slice(10, 20)
->filter(function (int $value): bool {
return $value % 2 === 0;
})
->map(function (int $value): int {
return $value + 2;
})
->each(function (int $value): void {
echo $value . "\n";
});
```

## Documentation

For full methods reference and more examples see [here](./docs/examples.md).
Expand Down
Loading

0 comments on commit c492612

Please sign in to comment.