Pipeline pattern
The Pipeline pattern is a design pattern used to process data in a series of sequential stages or steps.
- it passes data from one class to another
- example: middleware in Laravel
Laravel example
use Closure;
use App\Models\User;
use Illuminate\Support\Facades\Pipeline;
$user = Pipeline::send($user)
->through([
function (User $user, Closure $next) {
// ...
return $next($user);
},
function (User $user, Closure $next) {
// ...
return $next($user);
},
])
->then(fn (User $user) => $user);