The Pipeline pattern in Laravel

Code
<?php

use Illuminate\Pipeline\Pipeline;
use 
Illuminate\Container\Container;

// Build container and services
$container = new Container();

$container->bind('lcase', function() {
    return new class
    {
        public function 
handle($strClosure $pipe)
        {
            
$str $pipe($str);
            return 
strtolower($str);
        }
    };
});
$container->bind('trim_str', function() {
    return new class
    {
        public function 
handle($strClosure $pipe)
        {
            
$str $pipe($str);
            return 
trim($str);
        }
    };
});
$container->bind('remove_foo', function() {
    return new class
    {
        public function 
handle($strClosure $pipe)
        {
            
$str $pipe($str);
            return 
str_replace('foo'''$str);
        }
    };
});

// create Pipeline
$pipeline = new Pipeline($container);
// The value that will be send through every pipe
$pipeline->send('  barFoo  ');
// An array of pipes (service ids)
$pipeline->through(['remove_foo''trim_str''lcase']);

// Run sent value through pipeline
$result $pipeline->then(function($str) {
    return 
$str;
});

dump($result);
Result
^ "bar"
Used Versions
PHP 8.2, Laminas MVC 3.2, Symfony 5.2, Laravel 8.28, PHPUnit 9.5, Doctrine ORM 2.8