/** * {@inheritdoc} */ public function getReasonPhrase() { if ($this->reasonPhrase == '') { $this->reasonPhrase = HttpStatus::getReasonPhrase($this->statusCode); } return $this->reasonPhrase; }
/** * Get the exception information. * * @param string $id * @param int $code * * @return array */ public function generate(string $id, int $code) : array { try { $info = ['id' => $id, 'code' => $code, 'name' => HttpStatus::getReasonPhrase($code), 'detail' => HttpStatus::getReasonMessage($code)]; } catch (InvalidArgumentException $error) { $info = ['id' => $id, 'code' => 500, 'name' => HttpStatus::getReasonPhrase(500), 'detail' => HttpStatus::getReasonMessage(500)]; } $info['summary'] = 'Houston, We Have A Problem.'; return $info; }
/** * {@inheritdoc} */ public function render(ServerRequestInterface $request, Throwable $exception) : ResponseInterface { $transformed = $this->getTransformed($exception); try { $response = $this->getResponse($this->getContainer()->get(ServerRequestInterface::class), $exception, $transformed); return $response; } catch (Throwable $error) { $this->report($error); $response = $this->getContainer()->get(ResponseInterface::class); $response = $response->withStatus(500, HttpStatus::getReasonPhrase(500)); return $response; } }
/** * @expectedException OutOfBoundsException * @expectedExceptionMessage Unknown http status code: `509`. */ public function testGetReasonPhraseToThrowOutOfBoundsException() { HttpStatus::getReasonPhrase(509); }