Skip to content

Commit

Permalink
Updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
sanmai committed Mar 14, 2018
1 parent d97d4ce commit 7dedb25
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions README.md
Expand Up @@ -200,7 +200,7 @@ foreach ($pipeline as $result) {

# Known caveats

- Since all callback are lazily evaluated as more data coming in and out, make sure you consume the results with a plain `foreach` or use a `reduce()`.
- Since all callback are [lazily evaluated](https://en.wikipedia.org/wiki/Lazy_evaluation) as more data coming in and out, you must consume the results with a plain `foreach` or use a `reduce()` to make sure processing happens.

foreach ($pipeline as $result) {
// Processing happens only if you consume the results.
Expand All @@ -219,6 +219,8 @@ foreach ($pipeline as $result) {
- `\Pipeline\Principal` is an abstract class you may want to extend if you're not satisfied with defaults from the class above. E.g. `getIterator()` can have different error handling.
- Interface `Pipeline` defines three main functions all pipelines must bear.

This library is built to last. There's not a single place where an exception is thrown. Never mind any asserts whatsoever.

# Methods

## `__construct()`
Expand Down Expand Up @@ -337,17 +339,21 @@ API is expected to stay as simple as it is. Do not expect a PR with utility func

# About collection pipelines in general

What about alternatives? How are they different?
[About pipelines in general](https://martinfowler.com/articles/collection-pipeline/) from Martin Fowler.

What else is out there:

- [League\Pipeline](https://github.com/thephpleague/pipeline) is good for single values only. Similar name, but very different purpose. Not supposed to work with sequences of values. Each stage may return only one value.

- [Knapsack](https://github.com/DusanKasan/Knapsack) is a close call. Can take a Traversable as an input, has lazy evaluation. But can't have multiple values produced from a single input. Has lots of utility functions for those who need them: they're out of scope for this project.

- [transducers.php](https://github.com/mtdowling/transducers.php) is worth a close look if you're already familiar transducers from Clojure. API is not very PHP-esque. Read as not super friendly. [Detailed write-up from the author.](http://mtdowling.com/blog/2014/12/04/transducers-php/)

- Submit PR to add yours.
- [Functional PHP](https://github.com/lstrojny/functional-php) is supposed to complement currently exisiting PHP functions, which it does, although it is subject to some of the same shortcomings as are `array_map` and `array_filter`. No method chaining.

- [Chain](https://github.com/cocur/chain) provides a consistent and chainable way to work with arrays in PHP, although for arrays only. No lazy evaluation.

[More about pipelines in general](https://martinfowler.com/articles/collection-pipeline/) from Martin Fowler.
- Submit a PR to add yours.


# TODO
Expand Down

0 comments on commit 7dedb25

Please sign in to comment.