webbhuset / pipeline
A library of data-manipulation functions.
Installs: 4 712
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 10
Forks: 0
Open Issues: 0
Requires
- php: >=7.0
Requires (Dev)
- giorgiosironi/eris: ^0.13.0
- phpunit/phpunit: >=7
This package is auto-updated.
Last update: 2025-03-18 17:09:06 UTC
README
Pipeline is a PHP library for building reusable functions for manipulating values. Every Pipeline function is a class implementing __invoke(), thus allowing instances to be run as functions. Every function takes a Traversable as input and returns a Generator.
Documentation
Documentation is available at ReadTheDocs.
Example
<?php use Webbhuset\Pipeline\Constructor as F; $fun = F::Compose([ F::Map('trim'), F::Filter('is_numeric'), F::Map('intval'), F::Drop(2), F::Multiplex( function ($value) { return $value % 10 == 0 ? 'divide' : 'double'; }, [ 'divide' => F::Map(function ($value) { return $value / 10; }), 'double' => F::Map(function ($value) { return $value * 2; }), ] ) ]); $input = [ 1, ' 23 ', 'hello', '4.444', 5.75, '+12e3' ]; echo json_encode(iterator_to_array($fun($input))); // Output: [8,10,1200]