SHARE
TWEET

Untitled

a guest May 25th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. class Pipeline
  3. {
  4.     public static function make_pipeline(...$funcs)
  5.     {
  6.         return function($arg) use ($funcs)
  7.         {
  8.             foreach ($funcs as $func) {
  9.                 if(isset($hasil)){
  10.                     $hasil = $func($hasil);
  11.                 }else{
  12.                     $hasil = $func($arg);
  13.                 }
  14.             }
  15.             return $hasil;
  16.         };
  17.     }
  18. }
  19.  
  20. $fun = Pipeline::make_pipeline(function($x) { return $x * 3; }, function($x) { return $x + 1; },
  21.                           function($x) { return $x / 2; });
  22. echo $fun(3);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top