@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | RendererInterface $renderer, |
| 58 | 58 | ResponseFactoryInterface $responseFactory, |
| 59 | 59 | ContainerInterface $container |
| 60 | - ) { |
|
| 60 | + ){ |
|
| 61 | 61 | $this->suppressErrors = $suppressErrors; |
| 62 | 62 | $this->renderer = $renderer; |
| 63 | 63 | $this->responseFactory = $responseFactory; |
@@ -71,22 +71,22 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function process(Request $request, Handler $handler): Response |
| 73 | 73 | { |
| 74 | - try { |
|
| 74 | + try{ |
|
| 75 | 75 | return $handler->handle($request); |
| 76 | - } catch (ClientException | RouterException $e) { |
|
| 77 | - if ($e instanceof ClientException) { |
|
| 76 | + }catch (ClientException | RouterException $e){ |
|
| 77 | + if ($e instanceof ClientException){ |
|
| 78 | 78 | $code = $e->getCode(); |
| 79 | - } else { |
|
| 79 | + }else{ |
|
| 80 | 80 | $code = 404; |
| 81 | 81 | } |
| 82 | - } catch (\Throwable $e) { |
|
| 82 | + }catch (\Throwable $e){ |
|
| 83 | 83 | $snapshotter = $this->getOptional(SnapshotterInterface::class); |
| 84 | - if ($snapshotter !== null) { |
|
| 84 | + if ($snapshotter !== null){ |
|
| 85 | 85 | /** @var SnapshotterInterface $snapshotter */ |
| 86 | 86 | $snapshotter->register($e); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if (!$this->suppressErrors) { |
|
| 89 | + if (!$this->suppressErrors){ |
|
| 90 | 90 | return $this->renderError($request, $e); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | { |
| 110 | 110 | $response = $this->responseFactory->createResponse(500); |
| 111 | 111 | |
| 112 | - if ($request->getHeaderLine('Accept') == 'application/json') { |
|
| 112 | + if ($request->getHeaderLine('Accept') == 'application/json'){ |
|
| 113 | 113 | $response = $response->withHeader('Content-Type', 'application/json'); |
| 114 | 114 | $handler = new JsonHandler(); |
| 115 | 115 | $response->getBody()->write(json_encode( |
@@ -119,10 +119,10 @@ discard block |
||
| 119 | 119 | true |
| 120 | 120 | ) |
| 121 | 121 | )); |
| 122 | - } else { |
|
| 122 | + }else{ |
|
| 123 | 123 | $handler = new HtmlHandler(); |
| 124 | 124 | $state = $this->getOptional(StateInterface::class); |
| 125 | - if ($state !== null) { |
|
| 125 | + if ($state !== null){ |
|
| 126 | 126 | $handler = $handler->withState($state); |
| 127 | 127 | } |
| 128 | 128 | |
@@ -156,9 +156,9 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | private function getOptional(string $class) |
| 158 | 158 | { |
| 159 | - try { |
|
| 159 | + try{ |
|
| 160 | 160 | return $this->container->get($class); |
| 161 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
| 161 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
| 162 | 162 | return null; |
| 163 | 163 | } |
| 164 | 164 | } |
@@ -40,9 +40,9 @@ |
||
| 40 | 40 | public function renderException(Request $request, int $code, string $message): Response |
| 41 | 41 | { |
| 42 | 42 | $response = $this->responseFactory->createResponse($code); |
| 43 | - if ($request->getHeaderLine('Accept') == 'application/json') { |
|
| 43 | + if ($request->getHeaderLine('Accept') == 'application/json'){ |
|
| 44 | 44 | $response->getBody()->write(json_encode(['status' => $code, 'error' => $message])); |
| 45 | - } else { |
|
| 45 | + }else{ |
|
| 46 | 46 | $response->getBody()->write("Error code: {$code}"); |
| 47 | 47 | } |
| 48 | 48 | |