Response
class Response implements ArrayAccess (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. |
Methods
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 a header from the response.
Get the headers from the response.
Get the status code of the response.
Get the effective URI of the response.
Determine if the request was successful.
Determine if the response code was "OK".
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.
Get the response cookies.
Get the underlying PSR response for the response.
Throw an exception if a server or client error occurred.
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
static void
macro(string $name, object|callable $macro)
Register a custom macro.
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
static bool
hasMacro(string $name)
Checks if macro is registered.
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
mixed
__call(string $method, array $parameters)
Dynamically proxy other methods to the underlying response.
void
__construct(MessageInterface $response)
Create a new response instance.
string
body()
Get the body of the response.
mixed
json()
Get the JSON decoded body of the response as an array or scalar value.
object
object()
Get the JSON decoded body of the response as an object.
string
header(string $header)
Get a header from the response.
array
headers()
Get the headers from the response.
int
status()
Get the status code of the response.
UriInterface
effectiveUri()
Get the effective URI of the response.
bool
successful()
Determine if the request was successful.
bool
ok()
Determine if the response code was "OK".
bool
redirect()
Determine if the response was a redirect.
bool
failed()
Determine if the response indicates a client or server error occurred.
bool
clientError()
Determine if the response indicates a client error occurred.
bool
serverError()
Determine if the response indicates a server error occurred.
CookieJar
cookies()
Get the response cookies.
ResponseInterface
toPsrResponse()
Get the underlying PSR response for the response.
$this
throw()
Throw an exception if a server or client error occurred.
bool
offsetExists(string $offset)
Determine if the given offset exists.
mixed
offsetGet(string $offset)
Get the value for a given offset.
void
offsetSet(string $offset, mixed $value)
Set the value at the given offset.
void
offsetUnset(string $offset)
Unset the value at the given offset.
string
__toString()
Get the body of the response.