class Illuminate / Http / Client / Response

Response

Implements

Uses

Properties

protected

$response Psr\...\ResponseInterface

The underlying PSR response.

Default: null
protected

$decoded array

The decoded JSON response.

Default: null
public

$cookies GuzzleHttp\...\CookieJar

The request cookies.

Default: null
public

$transferStats GuzzleHttp\TransferStats|null

The transfer stats for the request.

Default: null

Methods

public

__construct ( $response ) : void

Create a new response instance.

Parameters

  • $response Psr\...\MessageInterface
public

body ( ) : string

Get the body of the response.

public

json ( $key , $default ) : mixed

Get the JSON decoded body of the response as an array or scalar value.

Parameters

  • $key string|null
  • $default mixed
public

object ( ) : object|null

Get the JSON decoded body of the response as an object.

public

collect ( $key ) : Illuminate\...\Collection

Get the JSON decoded body of the response as a collection.

Parameters

  • $key string|null
public

Get a header from the response.

Parameters

  • $header string
public

headers ( ) : array

Get the headers from the response.

public

status ( ) : int

Get the status code of the response.

public

reason ( ) : string

Get the reason phrase of the response.

public

effectiveUri ( ) : Psr\...\UriInterface|null

Get the effective URI of the response.

public

successful ( ) : bool

Determine if the request was successful.

public

redirect ( ) : bool

Determine if the response was a redirect.

public

failed ( ) : bool

Determine if the response indicates a client or server error occurred.

public

clientError ( ) : bool

Determine if the response indicates a client error occurred.

public

serverError ( ) : bool

Determine if the response indicates a server error occurred.

public

onError ( callable $callback ) : $this

Execute the given callback if there was a server or client error.

Parameters

  • $callback callable
public

cookies ( ) : GuzzleHttp\...\CookieJar

Get the response cookies.

public

handlerStats ( ) : array

Get the handler stats of the response.

public

close ( ) : $this

Close the stream and any underlying resources.

public

toPsrResponse ( ) : Psr\...\ResponseInterface

Get the underlying PSR response for the response.

public

toException ( ) : RequestException |null

Create an exception if a server or client error occurred.

public

throw ( ) : $this

Throw an exception if a server or client error occurred.

Parameters

public

throwIf ( $condition ) : $this

Throw an exception if a server or client error occurred and the given condition evaluates to true.

Parameters

public

throwIfStatus ( $statusCode ) : $this

Throw an exception if the response status code matches the given code.

Parameters

  • $statusCode callable|int
public

throwUnlessStatus ( $statusCode ) : $this

Throw an exception unless the response status code matches the given code.

Parameters

  • $statusCode callable|int
public

throwIfClientError ( ) : $this

Throw an exception if the response status code is a 4xx level code.

public

throwIfServerError ( ) : $this

Throw an exception if the response status code is a 5xx level code.

public

offsetExists ( $offset ) : bool

Determine if the given offset exists.

Parameters

  • $offset string
public

offsetGet ( $offset ) : mixed

Get the value for a given offset.

Parameters

  • $offset string
public

offsetSet ( $offset , $value ) : void

Set the value at the given offset.

Parameters

  • $offset string
  • $value mixed
public

offsetUnset ( $offset ) : void

Unset the value at the given offset.

Parameters

  • $offset string
public

__toString ( ) : string

Get the body of the response.

public

__call ( $method , $parameters ) : mixed

Dynamically proxy other methods to the underlying response.

Parameters

  • $method string
  • $parameters array