Skip to content

Instantly share code, notes, and snippets.

@acwoss
Created December 3, 2018 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acwoss/6652f4efbea8b44e0e85bccd890dc26b to your computer and use it in GitHub Desktop.
Save acwoss/6652f4efbea8b44e0e85bccd890dc26b to your computer and use it in GitHub Desktop.
class Pipeline implements RequestHandlerInterface
{
public function __constuct($handlers)
{
$this->handlers = $handlers;
}
public function handle(Request $request): Response
{
$handler = current($this->handlers);
next($this->handlers);
if ($handler intanceof MiddlewareInterface) {
return $handler->process($request, $this);
}
if ($handler intanceof RequestHandlerInterface) {
return $handler->handle($request);
}
return call_user_func_array($handler, [$request, $this]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment