1. Go to this page and download the library: Download samueldavis/php-pipeline 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/ */
samueldavis / php-pipeline example snippets
class Remover
{
public static function pop(array $arr = [])
{
return array_pop($arr);
}
}
$stringHelper = new class
{
public function concat(string $initial, string $addition): string
{
return $initial . $addition;
}
};
$explodeCurry = function (string $string) {
return explode(' ', $string);
};
$explodingPipeline = (new Pipe)
->into('strtoupper')
->into($explodeCurry);
$getResult = (new Pipe('foo bar'))
->into($explodingPipeline)
->into([Remover::class, 'pop'])
->into([$stringHelper, 'concat'], 'fiz');
var_dump($getResult());
echo "========\n" . json_encode($getResult, JSON_PRETTY_PRINT);