whoops = $whoops; $this->pageHandler = $pageHandler; $this->jsonHandler = $jsonHandler; } /** * Invoke the WhoopseMiddleware class. * * @param \Psr\Http\Message\ServerRequestInterface $request * @param \Psr\Http\Server\RequestHandlerInterface $handler * * @return \Psr\Http\Message\ResponseInterface */ public function __invoke(Request $request, RequestHandler $handler): ResponseInterface { $this->pageHandler->setPageTitle( sprintf('%s • Directory Lister', $this->pageHandler->getPageTitle()) ); $this->whoops->pushHandler($this->pageHandler); if (in_array('application/json', explode(',', $request->getHeaderLine('Accept')))) { $this->whoops->pushHandler($this->jsonHandler); } $this->whoops->register(); return $handler->handle($request); } }