This commit is contained in:
2021-04-20 13:48:33 +08:00
parent 23995df1af
commit f647b5bd39
2 changed files with 21 additions and 7 deletions
+18 -7
View File
@@ -52,13 +52,24 @@ class Reduce
private static function core(): Closure
{
return function ($stack, $pipe) {
return function ($passable) use ($stack, $pipe) {
if ($pipe instanceof Middleware) {
return $pipe->onHandler($passable, $stack);
} else {
return call_user_func($pipe, $passable, $stack);
}
};
return static::passable($stack, $pipe);
};
}
/**
* @param $stack
* @param $pipe
* @return Closure
*/
public static function passable($stack, $pipe): Closure
{
return function ($passable) use ($stack, $pipe) {
if (!($pipe instanceof Middleware)) {
return call_user_func($pipe, $passable, $stack);
} else {
return $pipe->onHandler($passable, $stack);
}
};
}