ResponseTrait
Table of Contents
- $exception : Exception|null
- The exception that triggered the error response (if applicable).
- $original : mixed
- The original content of the response.
- content() : string
- Get the content of the response.
- cookie() : $this
- Add a cookie to the response.
- getOriginalContent() : mixed
- Get the original response content.
- header() : $this
- Set a header on the Response.
- status() : int
- Get the status code for the response.
- throwResponse() : mixed
- Throws the response in a HttpResponseException instance.
- withCookie() : $this
- Add a cookie to the response.
- withException() : $this
- Set the exception to attach to the response.
- withHeaders() : $this
- Add an array of headers to the response.
Properties
$exception
The exception that triggered the error response (if applicable).
public
Exception|null
$exception
$original
The original content of the response.
public
mixed
$original
Methods
content()
Get the content of the response.
public
content() : string
Return values
string —cookie()
Add a cookie to the response.
public
cookie(Cookie|mixed $cookie) : $this
Parameters
- $cookie : Cookie|mixed
Return values
$this —getOriginalContent()
Get the original response content.
public
getOriginalContent() : mixed
Return values
mixed —header()
Set a header on the Response.
public
header(string $key, array<string|int, mixed>|string $values[, bool $replace = true ]) : $this
Parameters
- $key : string
- $values : array<string|int, mixed>|string
- $replace : bool = true
Return values
$this —status()
Get the status code for the response.
public
status() : int
Return values
int —throwResponse()
Throws the response in a HttpResponseException instance.
public
throwResponse() : mixed
Tags
Return values
mixed —withCookie()
Add a cookie to the response.
public
withCookie(Cookie|mixed $cookie) : $this
Parameters
- $cookie : Cookie|mixed
Return values
$this —withException()
Set the exception to attach to the response.
public
withException(Exception $e) : $this
Parameters
- $e : Exception
Return values
$this —withHeaders()
Add an array of headers to the response.
public
withHeaders(HeaderBag|array<string|int, mixed> $headers) : $this
Parameters
- $headers : HeaderBag|array<string|int, mixed>