Created
December 3, 2018 16:26
-
-
Save acwoss/6652f4efbea8b44e0e85bccd890dc26b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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