public function Response::withStatus in Zircon Profile 8
Same name in this branch
- 8 vendor/zendframework/zend-diactoros/src/Response.php \Zend\Diactoros\Response::withStatus()
- 8 vendor/guzzlehttp/psr7/src/Response.php \GuzzleHttp\Psr7\Response::withStatus()
- 8 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Response.php \Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\Response::withStatus()
Same name and namespace in other branches
- 8.0 vendor/guzzlehttp/psr7/src/Response.php \GuzzleHttp\Psr7\Response::withStatus()
Return an instance with the specified status code and, optionally, reason phrase.
If no reason phrase is specified, implementations MAY choose to default to the RFC 7231 or IANA recommended reason phrase for the response's status code.
This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the updated status and reason phrase.
@link http://tools.ietf.org/html/rfc7231#section-6 @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
Parameters
int $code The 3-digit integer result code to set.:
string $reasonPhrase The reason phrase to use with the: provided status code; if none is provided, implementations MAY use the defaults as suggested in the HTTP specification.
Return value
self
Throws
\InvalidArgumentException For invalid status code arguments.
Overrides ResponseInterface::withStatus
File
- vendor/
guzzlehttp/ psr7/ src/ Response.php, line 120
Class
- Response
- PSR-7 response implementation.
Namespace
GuzzleHttp\Psr7Code
public function withStatus($code, $reasonPhrase = '') {
$new = clone $this;
$new->statusCode = (int) $code;
if (!$reasonPhrase && isset(self::$phrases[$new->statusCode])) {
$reasonPhrase = self::$phrases[$new->statusCode];
}
$new->reasonPhrase = $reasonPhrase;
return $new;
}