Response
Implements
Uses
Properties
$response Psr\...\ResponseInterface
The underlying PSR response.
$decoded array
The decoded JSON response.
$cookies GuzzleHttp\...\CookieJar
The request cookies.
$transferStats GuzzleHttp\TransferStats|null
The transfer stats for the request.
Methods
__construct ( $response ) : void
Create a new response instance.
Parameters
- $response Psr\...\MessageInterface
body ( ) : string
Get the body of the response.
json ( $key , $default ) : mixed
Get the JSON decoded body of the response as an array or scalar value.
Parameters
- $key string|null
- $default mixed
object ( ) : object|null
Get the JSON decoded body of the response as an object.
collect ( $key ) : Illuminate\...\Collection
Get the JSON decoded body of the response as a collection.
Parameters
- $key string|null
header ( string $header ) : string
Get a header from the response.
Parameters
- $header string
headers ( ) : array
Get the headers from the response.
status ( ) : int
Get the status code of the response.
reason ( ) : string
Get the reason phrase of the response.
effectiveUri ( ) : Psr\...\UriInterface|null
Get the effective URI of the response.
successful ( ) : bool
Determine if the request was successful.
redirect ( ) : bool
Determine if the response was a redirect.
failed ( ) : bool
Determine if the response indicates a client or server error occurred.
clientError ( ) : bool
Determine if the response indicates a client error occurred.
serverError ( ) : bool
Determine if the response indicates a server error occurred.
onError ( callable $callback ) : $this
Execute the given callback if there was a server or client error.
Parameters
- $callback callable
cookies ( ) : GuzzleHttp\...\CookieJar
Get the response cookies.
handlerStats ( ) : array
Get the handler stats of the response.
close ( ) : $this
Close the stream and any underlying resources.
toPsrResponse ( ) : Psr\...\ResponseInterface
Get the underlying PSR response for the response.
toException ( ) : RequestException |null
Create an exception if a server or client error occurred.
throw ( ) : $this
Throw an exception if a server or client error occurred.
Parameters
- $callback Closure |null
throwIf ( $condition ) : $this
Throw an exception if a server or client error occurred and the given condition evaluates to true.
Parameters
throwIfStatus ( $statusCode ) : $this
Throw an exception if the response status code matches the given code.
Parameters
- $statusCode callable|int
throwUnlessStatus ( $statusCode ) : $this
Throw an exception unless the response status code matches the given code.
Parameters
- $statusCode callable|int
throwIfClientError ( ) : $this
Throw an exception if the response status code is a 4xx level code.
throwIfServerError ( ) : $this
Throw an exception if the response status code is a 5xx level code.
offsetExists ( $offset ) : bool
Determine if the given offset exists.
Parameters
- $offset string
offsetGet ( $offset ) : mixed
Get the value for a given offset.
Parameters
- $offset string
offsetSet ( $offset , $value ) : void
Set the value at the given offset.
Parameters
- $offset string
- $value mixed
offsetUnset ( $offset ) : void
Unset the value at the given offset.
Parameters
- $offset string
__toString ( ) : string
Get the body of the response.
__call ( $method , $parameters ) : mixed
Dynamically proxy other methods to the underlying response.
Parameters
- $method string
- $parameters array