Menu

## Response
in package

Response.php : 21

### 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

Response.php : 55
`public string $acceptMimeType`

#### $acceptParams

Response.php : 57
`public array<string|int, mixed> $acceptParams = []`

#### $charset

Response.php : 83
`public string $charset = 'UTF-8'`

#### $content

Response.php : 76

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

Response.php : 67

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

Response.php : 53
`public string $format = SnajuInceptionHttpResponseEnumsResponseFormat::JSON`

#### $formatters

Response.php : 59
`public array<string|int, mixed> $formatters = []`

#### $httpStatusCodes

Response.php : 91
`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']`

#### $isSent

Response.php : 89
`public bool $isSent = false`

#### $protocolVersion

Response.php : 87
`public string $protocolVersion`

#### $statusText

Response.php : 85
`public string $statusText = 'OK'`

#### $stream

Response.php : 81
`public mixed $stream`

#### $cookies

Response.php : 165
`private Collection $cookies`

#### $defaultFormatters

Response.php : 24
`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' => []]]`

#### $headers

Response.php : 163
`private Collection $headers`

#### $statusCode

Response.php : 161
`private int $statusCode = 200`

### Methods

#### __construct()

Response.php : 172
`public __construct() : mixed`

##### Return values

mixed —

#### addData()

Response.php : 481

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()

Response.php : 607
`public clear() : mixed`

##### Return values

mixed —

#### clearData()

Response.php : 489

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

`public clearData() : void`

##### Return values

void —

#### getCookieCollection()

Response.php : 367
`public getCookieCollection() : Collection`

##### Return values

Collection —

#### getCookieLine()

Response.php : 377
`public getCookieLine(mixed $name) : string`

##### Parameters

$name : mixed

##### Return values

string —

#### getCookies()

Response.php : 372
`public getCookies() : array<string|int, mixed>`

##### Return values

array<string|int, mixed> —

#### getHeaderCollection()

Response.php : 213
`public getHeaderCollection() : Collection`

##### Return values

Collection —

#### getHeaderLine()

Response.php : 299

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()

Response.php : 243

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()

Response.php : 190

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()

Response.php : 532

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()

Response.php : 423

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()

Response.php : 256

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()

Response.php : 462
`public hasValidStatusCode() : bool`

##### Return values

bool —

#### prepare()

Response.php : 542

Prepares the response to be sent by applying formatter, setting headers, codes, etc.

`public prepare() : void`

##### Tags

throws
  InvalidConfigException
throws
  InvalidArgumentException

##### Return values

void —

#### send()

Response.php : 705
`public send() : mixed`

##### Return values

mixed —

#### sendContent()

Response.php : 695
`public sendContent() : mixed`

##### Return values

mixed —

#### sendCookies()

Response.php : 660
`public sendCookies() : mixed`

##### Return values

mixed —

#### sendHeaders()

Response.php : 619
`public sendHeaders() : mixed`

##### Return values

mixed —

#### setData()

Response.php : 472

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()

Response.php : 428
`public setStatusCode(int $code[, mixed $reasonPhrase = null ]) : Response`

##### Parameters

$code : int
$reasonPhrase : mixed = null

##### Return values

Response —

#### setStatusCodeByException()

Response.php : 450
`public setStatusCodeByException(mixed $exception) : Response`

##### Parameters

$exception : mixed

##### Return values

Response —

#### getDefaultFormatters()

Response.php : 167
`private getDefaultFormatters() : array<string|int, mixed>`

##### Return values

array<string|int, mixed> —

## Search results