Download the PHP package ice-cream/pipeline without Composer
On this page you can find all versions of the php package ice-cream/pipeline. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ice-cream/pipeline
More information about ice-cream/pipeline
Files in ice-cream/pipeline
Package pipeline
Short Description ice-cream pipeline is used to pass something through a pipeline and have it processed and passed back out.
License MIT
Homepage http://adambalan.com/
Informations about the package pipeline
Ice Cream Pipeline
This is a basic implementation of the pipeline pattern, wherein something is passed through a series of classes and the end result is passed out.
- Requires PHP 7.2
- Is standalone
Purpose
I wanted to build this for the Ice cream framework, it would be useful in passing object in through a pipeline and manipulating them.
I also built this to learn the pipeline pattern and how it is used and how other frameworks use the pattern when manipulating objects.
Install
composer require ice-cream/pipeline
Documentation
You can see the full documentation for the project here
How to use?
What you will notice here is that we have a set of classes, the value 10 is passed through
both of these and then returned in the getResponse(), the reason we do not do this, returning the response
in process, is because you might want to call a new method: then() which takes a closure, as you will see in the examples below.
then(\Closure $func)
Building on the above example, lets assume you want to do something after you process the value, or object passed in:
You cannot call getResponse because this is a closure, and anonymous function.
What if I don't have a custom method?
Building on the above, we see that the classes, AddOne and TimesTwo implement a handle() method. If you do not
define a withMethod(String $string) then we default to the handle method that must be implemented or you get an \Exception
thrown telling you which class failed to implement the method in question.