haruncpi/fluent-pipe

Enables fluent value transformation via chained callbacks

v1.0.0 2025-07-16 15:22 UTC

This package is not auto-updated.

Last update: 2025-07-17 13:51:03 UTC


README

Enables fluent value transformation via chained callbacks

Installation

composer require haruncpi/fluent-pipe

Usage

use Haruncpi\FluentPipe\FluentPipe;

$text = FluentPipe::from(' hello fluent pipe!')
    ->then(fn($text) => trim($text))
    ->then(fn($text) => explode(' ', $text))
    ->then(fn($text) => array_map(fn($word) => ucfirst($word), $text))
    ->then(fn($array) => implode(' ', $array))
    ->get();

echo $text; // Hello Fluent Pipe!

Or

use Haruncpi\FluentPipe\FluentPipe;

$text = FluentPipe::from(' hello fluent pipe!')
    ->through([
        fn($text) => trim($text),
        fn($text) => explode(' ', $text),
        fn($text) => array_map(fn($word) => ucfirst($word), $text),
        fn($array) => implode(' ', $array),
    ])
    ->get();

var_dump($text); // Hello Fluent Pipe!

License

CC BY 4.0