PHP Class Bluz\Response\Response

Author: Anton Shevchuk
Inheritance: use trait Bluz\Common\Options
Afficher le fichier Open project: bluzphp/framework Class Usage Examples

Protected Properties

Свойство Type Description
$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

Méthodes publiques

Méthode Description
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

Méthodes protégées

Méthode Description
sendCookies ( ) : void Process Cookies to Header

Method Details

addHeader() public méthode

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
Résultat void

addHeaders() public méthode

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
Résultat void

clearBody() public méthode

Clear response body
public clearBody ( ) : void
Résultat void

getBody() public méthode

Get response body
public getBody ( ) : Controller | Bluz\Layout\Layout
Résultat Bluz\Controller\Controller | Bluz\Layout\Layout

getCookie() public méthode

Get Cookie by name
public getCookie ( string $name ) : array | null
$name string
Résultat array | null

getHeader() public méthode

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.
Résultat string

getHeaderAsArray() public méthode

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.
Résultat string[]

getHeaders() public méthode

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
Résultat array returns an associative array of the message's headers.

getProtocolVersion() public méthode

The string MUST contain only the HTTP version number (e.g., "1.1", "1.0").
public getProtocolVersion ( ) : string
Résultat string HTTP protocol version.

getReasonPhrase() public méthode

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
Résultat string | null reason phrase, or null if unknown.

getStatusCode() public méthode

The Status-Code is a 3-digit integer result code of the server's attempt to understand and satisfy the request.
public getStatusCode ( ) : integer
Résultat integer status code.

hasHeader() public méthode

Checks if a header exists by the given case-insensitive name
public hasHeader ( string $header ) : boolean
$header string case-insensitive header name.
Résultat 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() public méthode

Remove a specific header by case-insensitive name.
public removeHeader ( string $header ) : void
$header string HTTP header to remove
Résultat void

removeHeaders() public méthode

Remove all headers
public removeHeaders ( ) : void
Résultat void

send() public méthode

send
public send ( )

sendCookies() protected méthode

Set-Cookie: =[; =]... [; expires=][; domain=] [; path=][; secure][; httponly]
protected sendCookies ( ) : void
Résultat void

setBody() public méthode

Set response body
public setBody ( mixed $body ) : void
$body mixed
Résultat void

setCookie() public méthode

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
Résultat void

setHeader() public méthode

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)
Résultat void

setHeaders() public méthode

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.
Résultat void

setReasonPhrase() public méthode

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() public méthode

Sets the status code of this response
public setStatusCode ( integer $code ) : void
$code integer the 3-digit integer result code to set.
Résultat void

switchType() public méthode

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

Property Details

$body protected_oe property

result can be Controller|Layout
protected $body

$code protected_oe property

response code equal to HTTP status codes
protected $code

$cookies protected_oe property

list of cookies
protected $cookies

$headers protected_oe property

list of headers
protected $headers

$phrase protected_oe property

HTTP Phrase
protected $phrase

$protocol protected_oe property

HTTP protocol version
protected $protocol

$type protected_oe property

CLI|HTML|JSON
protected $type