Download the PHP package inmanturbo/pipes without Composer
On this page you can find all versions of the php package inmanturbo/pipes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download inmanturbo/pipes
More information about inmanturbo/pipes
Files in inmanturbo/pipes
Package pipes
Short Description Pipes for php with a simple api based on functional composition
License MIT
Informations about the package pipes
Pipes for php with a simple api based on functional composition
Simply put, it takes the output of the last one and pipes it to the next one. Sorta like bash cat ./file | grep -e 'waldo'
Installation
You can install the package via composer:
Or just copy or download the functions.php
file from this repository.
Usage
pipe()
It doesn't delay execution
You can also pass a class or a class string
Returning results
results can be returned three ways:
then()
or thenReturn()
both a take final callback and return the result, or result()
, which simply returns the result.
Halting the pipeline
halt()
You can return halt()
from a callback to halt the chain. halt
takes an optional result as an argument which you can pass as the final result()
of the chain. Subsequent calls to ->pipe()
will not affect the final result.
You can also call halt on the pipe itself
resume()
You can resume the piping with resume. pipe()->resume()
takes an optional callback and behaves the same as pipe()->pipe()
if a callback is passed
hop() and Laravel
This package doesn't require laravel to use pipe or hop()
, but hop()
(higher-order-pipe) is a higher order function intended for working with Laravel's Pipeline helper. This higher-order-function takes a callback which takes a single argument, and wraps the $callback
for you in a closure which implements function($next, $passable)
.
You can optionally pass a single middleware
as a second argument to hop()
, and it will get called before the first argument, which allows you to determine if the pipeline should halt before the $callback
ever gets executed.