PHP code example of moirei / pipeline

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

    

moirei / pipeline example snippets


$value = Pipeline::with(0)->pipe([
    Pipeline::switch([
        fn ($v) => $v + 1,
        fn ($v) => $v + 2,
        fn ($v) => $v + 3,
    ]),
    Pipeline::map(
        fn ($v) => $v * 2,
    ),
    Pipeline::tap(function (array $value) {
        // do whatever
    }),
]);

// returns [2, 4, 6]