@@ -35,14 +35,14 @@ If your variable is already an instance of `Traversable` (i.e. an `Iterator`, an
3535If your variable is an array, the function converts it to an ` ArrayIterator ` .
3636
3737Usage:
38+
3839``` php
3940use function BenTools\IterableFunctions\iterable_to_traversable;
4041
4142var_dump(iterable_to_traversable(['foo', 'bar'])); // \ArrayIterator(['foo', 'bar'])
4243var_dump(iterable_to_traversable(new \ArrayIterator(['foo', 'bar']))); // \ArrayIterator(['foo', 'bar'])
4344```
4445
45-
4646iterable_map()
4747--------------
4848
@@ -102,6 +102,7 @@ foreach (iterable_filter($generator()) as $item) {
102102```
103103
104104Of course you can define your own filter:
105+
105106``` php
106107use function BenTools\IterableFunctions\iterable_filter;
107108
@@ -126,6 +127,7 @@ Iterable fluent interface
126127The ` iterable ` function allows you to wrap an iterable and apply some common operations.
127128
128129With an array input:
130+
129131``` php
130132use function BenTools\IterableFunctions\iterable;
131133$data = [
@@ -138,6 +140,7 @@ $iterable = iterable($data)->filter(fn($eatable) => 'rock' !== $eatable)->map('s
138140```
139141
140142With a traversable input:
143+
141144``` php
142145use function BenTools\IterableFunctions\iterable;
143146$data = [
@@ -152,20 +155,22 @@ $iterable = iterable($data())->filter(fn($eatable) => 'rock' !== $eatable)->map(
152155```
153156
154157Array output:
158+
155159``` php
156160$iterable->asArray(); // array ['banana', 'pineapple']
157161```
158162
159-
160163Installation
161164============
162165
163166With composer (they'll be autoloaded):
167+
164168```
165169composer require bentools/iterable-functions
166170```
167171
168172Or manually:
173+
169174``` php
170175require_once '/path/to/this/library/src/iterable-functions.php';
171176```
0 commit comments