Response
class Response implements ArrayAccess, Stringable mixin ResponseInterface (View source)
Traits
Properties
static protected array | $macros | The registered string macros. |
from Macroable |
protected ResponseInterface | $response | The underlying PSR response. |
|
protected array | $decoded | The decoded JSON response. |
|
CookieJar | $cookies | The request cookies. |
|
TransferStats|null | $transferStats | The transfer stats for the request. |
Methods
Determine if the response code was 202 "Accepted" response.
Determine if the response code was the given status code and the body has no content.
Determine if the response code was a 301 "Moved Permanently".
Determine if the response code was a 304 "Not Modified" response.
Determine if the response was a 400 "Bad Request" response.
Determine if the response was a 401 "Unauthorized" response.
Determine if the response was a 402 "Payment Required" response.
Determine if the response was a 403 "Forbidden" response.
Determine if the response was a 408 "Request Timeout" response.
Determine if the response was a 422 "Unprocessable Content" response.
Determine if the response was a 422 "Unprocessable Content" response.
Determine if the response was a 429 "Too Many Requests" response.
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically proxy other methods to the underlying response.
Create a new response instance.
Get the body of the response.
Get the JSON decoded body of the response as an array or scalar value.
Get the JSON decoded body of the response as an object.
Get the JSON decoded body of the response as a collection.
Get the JSON decoded body of the response as a fluent object.
Get the body of the response as a PHP resource.
Get a header from the response.
Get the headers from the response.
Get the status code of the response.
Get the reason phrase of the response.
Get the effective URI of the response.
Determine if the request was successful.
Determine if the response was a redirect.
Determine if the response indicates a client or server error occurred.
Determine if the response indicates a client error occurred.
Determine if the response indicates a server error occurred.
Execute the given callback if there was a server or client error.
Get the response cookies.
Get the handler stats of the response.
Close the stream and any underlying resources.
Get the underlying PSR response for the response.
Create an exception if a server or client error occurred.
Throw an exception if a server or client error occurred.
Throw an exception if the response status code matches the given code.
Throw an exception unless the response status code matches the given code.
Throw an exception if the response status code is a 4xx level code.
Throw an exception if the response status code is a 5xx level code.
Dump the content from the response.
Dump the content from the response and end the script.
Dump the headers from the response.
Dump the headers from the response and end the script.
Determine if the given offset exists.
Get the value for a given offset.
Set the value at the given offset.
Unset the value at the given offset.
Get the body of the response.
Details
bool
noContent(int $status = 204)
Determine if the response code was the given status code and the body has no content.
mixed
__call(string $method, array $parameters)
Dynamically proxy other methods to the underlying response.
mixed
json(string|null $key = null, mixed $default = null)
Get the JSON decoded body of the response as an array or scalar value.
Collection
collect(string|null $key = null)
Get the JSON decoded body of the response as a collection.
Fluent
fluent(string|null $key = null)
Get the JSON decoded body of the response as a fluent object.
$this
throwIf(Closure|bool $condition)
Throw an exception if a server or client error occurred and the given condition evaluates to true.
$this
throwIfStatus(callable|int $statusCode)
Throw an exception if the response status code matches the given code.
$this
throwUnlessStatus(callable|int $statusCode)
Throw an exception unless the response status code matches the given code.