PHP code example of yaroslawww / php-pipe-passage

1. Go to this page and download the library: Download yaroslawww/php-pipe-passage 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/ */

    

yaroslawww / php-pipe-passage example snippets

bash
composer 
injectablephp
 $pipe = Pipe::make([
    function ($entity, \Closure $next) {
        $entity->test = 'test value';

        return $next($entity);
    },
    function ($entity, \Closure $next) {
        $entity->test2 = 'second test value';

        return $next($entity);
    },
])
            ->next(SetNameHandler::class)
            ->next(new SetCompanyHandler('web company'))
            ->next(function ($entity, \Closure $next) {
                $entity->test3 = 'third test value';

                return $next($entity);
            });

$entityObject = $pipe->pass(new \stdClass());

$this->assertEquals('test value', $entityObject->test);
$this->assertEquals('second test value', $entityObject->test2);
$this->assertEquals('third test value', $entityObject->test3);
$this->assertEquals('default', $entityObject->name);
$this->assertEquals('web company', $entityObject->company);