PHP Класс Bluz\Response\Response

Автор: Anton Shevchuk
Наследование: use trait Bluz\Common\Options
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$body result can be Controller|Layout
$code response code equal to HTTP status codes
$cookies list of cookies
$headers list of headers
$phrase HTTP Phrase
$protocol HTTP protocol version
$type CLI|HTML|JSON

Открытые методы

Метод Описание
addHeader ( string $header, string $value ) : void Appends a header value for the specified header
addHeaders ( array $headers ) : void Merges in an associative array of headers.
clearBody ( ) : void Clear response body
getBody ( ) : Controller | Bluz\Layout\Layout Get response body
getCookie ( string $name ) : array | null Get Cookie by name
getHeader ( string $header ) : string Retrieve a header by the given case-insensitive name as a string
getHeaderAsArray ( string $header ) : string[] Retrieves a header by the given case-insensitive name as an array of strings
getHeaders ( ) : array Gets all message headers
getProtocolVersion ( ) : string Gets the HTTP protocol version as a string
getReasonPhrase ( ) : string | null Gets the response Reason-Phrase, a short textual description of the Status-Code
getStatusCode ( ) : integer Gets the response Status-Code
hasHeader ( string $header ) : boolean Checks if a header exists by the given case-insensitive name
removeHeader ( string $header ) : void Remove a specific header by case-insensitive name.
removeHeaders ( ) : void Remove all headers
send ( ) send
setBody ( mixed $body ) : void Set response body
setCookie ( string $name, string $value = '', integer | string | DateTime $expire, string $path = '/', string $domain = '', boolean $secure = false, boolean $httpOnly = false ) : void Set Cookie
setHeader ( string $header, string | string[] $value ) : void Sets a header, replacing any existing values of any headers with the same case-insensitive name
setHeaders ( array $headers ) : void Sets headers, replacing any headers that have already been set on the message
setReasonPhrase ( string $phrase ) Sets the Reason-Phrase of the response
setStatusCode ( integer $code ) : void Sets the status code of this response
switchType ( $type ) Set Response Type, one of JSON, HTML or CLI

Защищенные методы

Метод Описание
sendCookies ( ) : void Process Cookies to Header

Описание методов

addHeader() публичный Метод

Existing values for the specified header will be maintained. The new value will be appended to the existing list.
public addHeader ( string $header, string $value ) : void
$header string header name to add
$value string value of the header
Результат void

addHeaders() публичный Метод

Each array key MUST be a string representing the case-insensitive name of a header. Each value MUST be either a string or an array of strings. For each value, the value is appended to any existing header of the same name, or, if a header does not already exist by the given name, then the header is added.
public addHeaders ( array $headers ) : void
$headers array Associative array of headers to add to the message
Результат void

clearBody() публичный Метод

Clear response body
public clearBody ( ) : void
Результат void

getBody() публичный Метод

Get response body
public getBody ( ) : Controller | Bluz\Layout\Layout
Результат Bluz\Controller\Controller | Bluz\Layout\Layout

getCookie() публичный Метод

Get Cookie by name
public getCookie ( string $name ) : array | null
$name string
Результат array | null

getHeader() публичный Метод

This method returns all of the header values of the given case-insensitive header name as a string concatenated together using a comma.
public getHeader ( string $header ) : string
$header string case-insensitive header name.
Результат string

getHeaderAsArray() публичный Метод

Retrieves a header by the given case-insensitive name as an array of strings
public getHeaderAsArray ( string $header ) : string[]
$header string Case-insensitive header name.
Результат string[]

getHeaders() публичный Метод

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); }
public getHeaders ( ) : array
Результат array returns an associative array of the message's headers.

getProtocolVersion() публичный Метод

The string MUST contain only the HTTP version number (e.g., "1.1", "1.0").
public getProtocolVersion ( ) : string
Результат string HTTP protocol version.

getReasonPhrase() публичный Метод

Because a Reason-Phrase is not a required element in response Status-Line, the Reason-Phrase value MAY be null. Implementations MAY choose to return the default RFC 2616 recommended reason phrase for the response's Status-Code.
public getReasonPhrase ( ) : string | null
Результат string | null reason phrase, or null if unknown.

getStatusCode() публичный Метод

The Status-Code is a 3-digit integer result code of the server's attempt to understand and satisfy the request.
public getStatusCode ( ) : integer
Результат integer status code.

hasHeader() публичный Метод

Checks if a header exists by the given case-insensitive name
public hasHeader ( string $header ) : boolean
$header string case-insensitive header name.
Результат boolean 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.

removeHeader() публичный Метод

Remove a specific header by case-insensitive name.
public removeHeader ( string $header ) : void
$header string HTTP header to remove
Результат void

removeHeaders() публичный Метод

Remove all headers
public removeHeaders ( ) : void
Результат void

send() публичный Метод

send
public send ( )

sendCookies() защищенный Метод

Set-Cookie: =[; =]... [; expires=][; domain=] [; path=][; secure][; httponly]
protected sendCookies ( ) : void
Результат void

setBody() публичный Метод

Set response body
public setBody ( mixed $body ) : void
$body mixed
Результат void

setCookie() публичный Метод

Set Cookie
public setCookie ( string $name, string $value = '', integer | string | DateTime $expire, string $path = '/', string $domain = '', boolean $secure = false, boolean $httpOnly = false ) : void
$name string
$value string
$expire integer | string | DateTime
$path string
$domain string
$secure boolean
$httpOnly boolean
Результат void

setHeader() публичный Метод

The header name is case-insensitive. The header values MUST be a string or an array of strings.
public setHeader ( string $header, string | string[] $value ) : void
$header string header name
$value string | string[] header value(s)
Результат void

setHeaders() публичный Метод

The array keys MUST be a string. The array values must be either a string or an array of strings.
public setHeaders ( array $headers ) : void
$headers array Headers to set.
Результат void

setReasonPhrase() публичный Метод

If no Reason-Phrase is specified, implementations MAY choose to default to the RFC 2616 recommended reason phrase for the response's Status-Code.
public setReasonPhrase ( string $phrase )
$phrase string the Reason-Phrase to set.

setStatusCode() публичный Метод

Sets the status code of this response
public setStatusCode ( integer $code ) : void
$code integer the 3-digit integer result code to set.
Результат void

switchType() публичный Метод

Set Response Type, one of JSON, HTML or CLI
public switchType ( $type )
$type

Описание свойств

$body защищенное свойство

result can be Controller|Layout
protected $body

$code защищенное свойство

response code equal to HTTP status codes
protected $code

$cookies защищенное свойство

list of cookies
protected $cookies

$headers защищенное свойство

list of headers
protected $headers

$phrase защищенное свойство

HTTP Phrase
protected $phrase

$protocol защищенное свойство

HTTP protocol version
protected $protocol

$type защищенное свойство

CLI|HTML|JSON
protected $type