Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Pipeline
- {
- public static function make_pipeline(...$funcs)
- {
- return function($arg) use ($funcs)
- {
- foreach ($funcs as $func) {
- if(isset($hasil)){
- $hasil = $func($hasil);
- }else{
- $hasil = $func($arg);
- }
- }
- return $hasil;
- };
- }
- }
- $fun = Pipeline::make_pipeline(function($x) { return $x * 3; }, function($x) { return $x + 1; },
- function($x) { return $x / 2; });
- echo $fun(3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement