public getStatusCode ( string $statusText ) : string | ||
$statusText | string | http status text |
Résultat | string | Returns code for the given status text |
public function getStatusCode($statusText)
{
$statusText = $this->filterReasonPhrase($statusText);
$statusCode = $this->fetchStatusCode($statusText);
if ($statusCode !== false) {
return $statusCode;
}
throw new OutOfBoundsException(sprintf('No Http status code is associated to `%s`', $statusText));
}
/** * Get the response with the status code from the payload. * * @param ResponseInterface $response * @param PayloadInterface $payload * * @return ResponseInterface */ private function status(ResponseInterface $response, PayloadInterface $payload) { $status = $payload->getStatus(); $code = $this->http_status->getStatusCode($status); return $response->withStatus($code); }