1. Go to this page and download the library: Download toobo/pipepie library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
toobo / pipepie example snippets
use Toobo\PipePie\Pipeline;
$pipeline = (new Pipeline())
->pipe(function($carry) {
return $carry.'B';
})->pipe(function($carry) {
return $carry.'C';
});
echo $pipeline->applyTo('A'); // 'ABC'
use Toobo\PipePie\Pipeline;
use Toobo\PipePie\DTO;
$pipeline = (new Pipeline())
->pipe(function($carry, $initial, DTO $dto) {
$dto['ai'] = new ArrayIterator();
$dto['ai']->append('bar');
})->pipe(function($carry, $initial, DTO $dto) {
$dto['ai']->append('baz');
})->pipe(function($carry, $initial, DTO $dto) {
return $carry.implode(',' $dto['ai']->getArrayCopy());
});
echo $pipeline->applyTo('foo,'); // 'foo,bar,baz'
use Toobo\PipePie\Pipeline;
use Toobo\PipePie\DTO;
// Context here is a string, but can be anything
$pipeline = (new Pipeline('I am the context '))
->pipe(function($carry, $initial, DTO $dto) {
return $carry.$dto->context();
})->pipe(function($carry, $initial, DTO $dto) {
return $carry.$dto->context();
});
echo $pipeline->applyTo('foo '); // 'foo I am the context I am the context'