Snaju Inception Docs

Response
in package

Table of Contents

$acceptMimeType  : string
$acceptParams  : array<string|int, mixed>
$charset  : string
$content  : mixed
Formatted data according to the set formatter. This is set automatically in the prepare method while the response is being sent. No content will be set if $this->data is empty.
$data  : mixed
Raw data that will be formatted according to the set format. After formatting, `$this->content` will be set.
$format  : string
$formatters  : array<string|int, mixed>
$httpStatusCodes  : array<string|int, mixed>
$isSent  : bool
$protocolVersion  : string
$statusText  : string
$stream  : mixed
$cookies  : Collection
$defaultFormatters  : array<string|int, mixed>
$headers  : Collection
$statusCode  : int
__construct()  : mixed
addData()  : void
Preservers the previously added data and adds new data to the data array.
clear()  : mixed
clearData()  : void
Clear the data array, removing any existing data previously set.
getCookieCollection()  : Collection
getCookieLine()  : string
getCookies()  : array<string|int, mixed>
getHeaderCollection()  : Collection
getHeaderLine()  : string
Retrieves a comma-separated string of the values for a single header.
getHeaders()  : array<string|int, array<string|int, string>>
Retrieves all message header values.
getProtocolVersion()  : string
Retrieves the HTTP protocol version as a string.
getReasonPhrase()  : string
Gets the response reason phrase associated with the status code.
getStatusCode()  : int
Gets the response status code.
hasHeader()  : bool
Checks if a header exists by the given case-insensitive name.
hasValidStatusCode()  : bool
prepare()  : void
Prepares the response to be sent by applying formatter, setting headers, codes, etc.
send()  : mixed
sendContent()  : mixed
sendCookies()  : mixed
sendHeaders()  : mixed
setData()  : void
Sets new data in the data array, clearing any previously set data.
setStatusCode()  : Response
setStatusCodeByException()  : Response
getDefaultFormatters()  : array<string|int, mixed>

Properties

$acceptMimeType

public string $acceptMimeType

$acceptParams

public array<string|int, mixed> $acceptParams = []

$charset

public string $charset = 'UTF-8'

$content

Formatted data according to the set formatter. This is set automatically in the prepare method while the response is being sent. No content will be set if $this->data is empty.

public mixed $content
Tags
see
data

$data

Raw data that will be formatted according to the set format. After formatting, `$this->content` will be set.

public mixed $data
Tags
see
content

$format

public string $format = SnajuInceptionHttpResponseEnumsResponseFormat::JSON

$formatters

public array<string|int, mixed> $formatters = []

$httpStatusCodes

public static array<string|int, mixed> $httpStatusCodes = [100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', 118 => 'Connection timed out', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-Status', 208 => 'Already Reported', 210 => 'Content Different', 226 => 'IM Used', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 306 => 'Reserved', 307 => 'Temporary Redirect', 308 => 'Permanent Redirect', 310 => 'Too many Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Time-out', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Requested range unsatisfiable', 417 => 'Expectation failed', 418 => 'I'm a teapot', 421 => 'Misdirected Request', 422 => 'Unprocessable entity', 423 => 'Locked', 424 => 'Method failure', 425 => 'Unordered Collection', 426 => 'Upgrade Required', 428 => 'Precondition Required', 429 => 'Too Many Requests', 431 => 'Request Header Fields Too Large', 449 => 'Retry With', 450 => 'Blocked by Windows Parental Controls', 451 => 'Unavailable For Legal Reasons', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway or Proxy Error', 503 => 'Service Unavailable', 504 => 'Gateway Time-out', 505 => 'HTTP Version not supported', 507 => 'Insufficient storage', 508 => 'Loop Detected', 509 => 'Bandwidth Limit Exceeded', 510 => 'Not Extended', 511 => 'Network Authentication Required']

$protocolVersion

public string $protocolVersion

$statusText

public string $statusText = 'OK'

$defaultFormatters

private array<string|int, mixed> $defaultFormatters = [SnajuInceptionHttpResponseEnumsResponseFormat::RAW => ['class' => SnajuInceptionHttpResponseFormattersRawResponseFormatter::class, 'options' => []], SnajuInceptionHttpResponseEnumsResponseFormat::HTML => ['class' => SnajuInceptionHttpResponseFormattersHtmlResponseFormatter::class, 'options' => []], SnajuInceptionHttpResponseEnumsResponseFormat::JSON => ['class' => SnajuInceptionHttpResponseFormattersJsonResponseFormatter::class, 'options' => []], SnajuInceptionHttpResponseEnumsResponseFormat::JSONP => ['class' => SnajuInceptionHttpResponseFormattersJsonResponseFormatter::class, 'options' => ['jsonp' => true]], SnajuInceptionHttpResponseEnumsResponseFormat::XML => ['class' => SnajuInceptionHttpResponseFormattersXmlResponseFormatter::class, 'options' => []], SnajuInceptionHttpResponseEnumsResponseFormat::TEXT => ['class' => SnajuInceptionHttpResponseFormattersTextResponseFormatter::class, 'options' => []]]

$statusCode

private int $statusCode = 200

Methods

__construct()

public __construct() : mixed
Return values
mixed

addData()

Preservers the previously added data and adds new data to the data array.

public addData([array<string|int, mixed> $data = [] ]) : void
Parameters
$data : array<string|int, mixed> = []
Return values
void

clear()

public clear() : mixed
Return values
mixed

clearData()

Clear the data array, removing any existing data previously set.

public clearData() : void
Return values
void

getCookieLine()

public getCookieLine(mixed $name) : string
Parameters
$name : mixed
Return values
string

getCookies()

public getCookies() : array<string|int, mixed>
Return values
array<string|int, mixed>

getHeaderLine()

Retrieves a comma-separated string of the values for a single header.

public getHeaderLine(string $name) : string

This method returns all of the header values of the given case-insensitive header name as a string concatenated together using a comma.

NOTE: Not all header values may be appropriately represented using comma concatenation. For such headers, use getHeader() instead and supply your own delimiter when concatenating.

If the header does not appear in the message, this method MUST return an empty string.

Parameters
$name : string

Case-insensitive header field name.

Return values
string

A string of values as provided for the given header concatenated together using a comma. If the header does not appear in the message, this method MUST return an empty string.

getHeaders()

Retrieves all message header values.

public getHeaders() : array<string|int, array<string|int, string>>

The keys represent the header name as it will be sent over the wire, and each value is an array of strings associated with the header.

// Represent the headers as a string
foreach ($message->getHeaders() as $name => $values) {
    echo $name . ": " . implode(", ", $values);
}

// Emit headers iteratively:
foreach ($message->getHeaders() as $name => $values) {
    foreach ($values as $value) {
        header(sprintf('%s: %s', $name, $value), false);
    }
}

While header names are not case-sensitive, getHeaders() will preserve the exact case in which headers were originally specified.

Return values
array<string|int, array<string|int, string>>

Returns an associative array of the message's headers. Each key MUST be a header name, and each value MUST be an array of strings for that header.

getProtocolVersion()

Retrieves the HTTP protocol version as a string.

public getProtocolVersion() : string

The string MUST contain only the HTTP version number (e.g., "1.1", "1.0").

Return values
string

HTTP protocol version.

getReasonPhrase()

Gets the response reason phrase associated with the status code.

public getReasonPhrase() : string

Because a reason phrase is not a required element in a response status line, the reason phrase value MAY be null. Implementations MAY choose to return the default RFC 7231 recommended reason phrase (or those listed in the IANA HTTP Status Code Registry) for the response's status code.

Tags
link
http://tools.ietf.org/html/rfc7231#section-6
link
http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
Return values
string

Reason phrase; must return an empty string if none present.

getStatusCode()

Gets the response status code.

public getStatusCode() : int

The status code is a 3-digit integer result code of the server's attempt to understand and satisfy the request.

Return values
int

Status code.

hasHeader()

Checks if a header exists by the given case-insensitive name.

public hasHeader(string $name) : bool
Parameters
$name : string

Case-insensitive header field name.

Return values
bool

Returns true if any header names match the given header name using a case-insensitive string comparison. Returns false if no matching header name is found in the message.

hasValidStatusCode()

public hasValidStatusCode() : bool
Return values
bool

send()

public send() : mixed
Return values
mixed

sendContent()

public sendContent() : mixed
Return values
mixed

sendCookies()

public sendCookies() : mixed
Return values
mixed

sendHeaders()

public sendHeaders() : mixed
Return values
mixed

setData()

Sets new data in the data array, clearing any previously set data.

public setData([array<string|int, mixed> $data = [] ]) : void
Parameters
$data : array<string|int, mixed> = []
Return values
void

setStatusCode()

public setStatusCode(int $code[, mixed $reasonPhrase = null ]) : Response
Parameters
$code : int
$reasonPhrase : mixed = null
Return values
Response

setStatusCodeByException()

public setStatusCodeByException(mixed $exception) : Response
Parameters
$exception : mixed
Return values
Response

getDefaultFormatters()

private getDefaultFormatters() : array<string|int, mixed>
Return values
array<string|int, mixed>

Search results