Trait ResponseTrait
Representation of an outgoing, server-side response.
Per the HTTP specification, this interface includes properties for each of the following:
- Protocol version
- Status code and reason phrase
- Headers
- Message body
Responses are considered immutable; all methods that might change state MUST be implemented such that they retain the internal state of the current message and return an instance that contains the changed state.
Traits provide extended method support to classes without requiring a direct, linear chain of inheritance. This allows functions to inherit subsets of related methods without declaring a parent class.
In Oroboros core, ALL methods are granted to classes via traits, and the classes themselves are just containers that correlate their methods to an interface they are expected to honor. This approach maximizes interoperability, by entirely removing class inheritance as a requirement for extension of any class in this system.
3rd parties using this package are not expected to follow this approach,
but ALL of our internal class and logic structure does.
- oroboros\core\traits\libraries\response\ResponseTrait uses oroboros\core\traits\libraries\stream\MessageTrait
Direct Known Users
Indirect Known Users
Package: oroboros\core\psr7
Category: traits
License: The MIT License (MIT)
Author: Brian Dayhoff mopsyd@me.com
Version: 0.2.4
Since: 0.2.4-alpha
Used by: oroboros\core\interfaces\api\psr\Psr7Api::RESPONSE_ABSTRACT_CLASS
Link: bitbucket.org/oroborosframework/oroboros-core/wiki/development/api/traits.md
Satisfies: \oroboros\core\interfaces\contract\libraries\request\ResponseContract
Satisfies: \Psr\Http\Message\ResponseInterface
Located at core/traits/libraries/response/ResponseTrait.php
Methods summary
public
|
#
__construct( scalar|resource|Psr\Http\Message\StreamInterface $body, array $headers = null, string $protocol = null, integer $code = null, string $reason = null )
|
public
integer
|
|
public
static
|
#
withStatus( integer $code, string $reasonPhrase = '' )
Return an instance with the specified status code and, optionally, reason phrase. |
public
string
|
|
protected
|
#
_initializeResponse( mixed $body, array $headers = null, array $protocol = null, string $code = null, $reason = null )
|
private
|
|
private
|
|
private
array
|
#
_getMessageValues( )
Returns an array of the existing message values for this object, for substitution when returning instances that must retain object immutability. |
private
|
|
private
oroboros\core\traits\libraries\request\ResponseTrait
|
#
_instantiateMessageNewInstance( array $params = null )
Creates a new instance based off of the default parameters, substituting any values passed in. |
Methods used from oroboros\core\traits\libraries\stream\MessageTrait
_checkMessageHeader()
,
_getMessageHeaders()
,
_getMessageValidRequestHeaders()
,
_getMessageValidResponseHeaders()
,
_initializeMessage()
,
_setMessageBody()
,
_setMessageHeaders()
,
_setMessageProtocol()
,
_validateMessageHeader()
,
getBody()
,
getHeader()
,
getHeaderLine()
,
getHeaders()
,
getProtocolVersion()
,
hasHeader()
,
withAddedHeader()
,
withBody()
,
withHeader()
,
withProtocolVersion()
,
withoutHeader()
Properties summary
private
|
$_response_code
Represents the internal status code object |
|
private
boolean
|
$_response_is_initialized
Represents whether the request has been correctly initialized. |
#
false
|