MessageTrait
Trait implementing functionality common to requests and responses.
Table of Contents
Properties
- $headerNames : array<string|int, string>
- $headers : array<string|int, array<string|int, string>>
- $protocol : string
- $stream : StreamInterface|null
Methods
- getBody() : StreamInterface
- getHeader() : array<string|int, mixed>
- getHeaderLine() : string
- getHeaders() : array<string|int, mixed>
- getProtocolVersion() : string
- hasHeader() : bool
- withAddedHeader() : MessageInterface
- withBody() : MessageInterface
- withHeader() : MessageInterface
- withoutHeader() : MessageInterface
- withProtocolVersion() : MessageInterface
- assertHeader() : void
- assertValue() : void
- normalizeHeaderValue() : array<string|int, string>
- setHeaders() : void
- trimAndValidateHeaderValues() : array<string|int, string>
- Trims whitespace from the header values.
Properties
$headerNames
private
array<string|int, string>
$headerNames
= []
Map of lowercase header name => original name at registration
$headers
private
array<string|int, array<string|int, string>>
$headers
= []
Map of all registered headers, as original name => array of values
$protocol
private
string
$protocol
= '1.1'
$stream
private
StreamInterface|null
$stream
Methods
getBody()
public
getBody() : StreamInterface
Return values
StreamInterfacegetHeader()
public
getHeader(mixed $header) : array<string|int, mixed>
Parameters
- $header : mixed
Return values
array<string|int, mixed>getHeaderLine()
public
getHeaderLine(mixed $header) : string
Parameters
- $header : mixed
Return values
stringgetHeaders()
public
getHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed>getProtocolVersion()
public
getProtocolVersion() : string
Return values
stringhasHeader()
public
hasHeader(mixed $header) : bool
Parameters
- $header : mixed
Return values
boolwithAddedHeader()
public
withAddedHeader(mixed $header, mixed $value) : MessageInterface
Parameters
- $header : mixed
- $value : mixed
Return values
MessageInterfacewithBody()
public
withBody(StreamInterface $body) : MessageInterface
Parameters
- $body : StreamInterface
Return values
MessageInterfacewithHeader()
public
withHeader(mixed $header, mixed $value) : MessageInterface
Parameters
- $header : mixed
- $value : mixed
Return values
MessageInterfacewithoutHeader()
public
withoutHeader(mixed $header) : MessageInterface
Parameters
- $header : mixed
Return values
MessageInterfacewithProtocolVersion()
public
withProtocolVersion(mixed $version) : MessageInterface
Parameters
- $version : mixed
Return values
MessageInterfaceassertHeader()
private
assertHeader(mixed $header) : void
Parameters
- $header : mixed
Tags
assertValue()
private
assertValue(string $value) : void
Parameters
- $value : string
Tags
normalizeHeaderValue()
private
normalizeHeaderValue(mixed $value) : array<string|int, string>
Parameters
- $value : mixed
Return values
array<string|int, string>setHeaders()
private
setHeaders(array<string|int, string|array<string|int, string>> $headers) : void
Parameters
- $headers : array<string|int, string|array<string|int, string>>
trimAndValidateHeaderValues()
Trims whitespace from the header values.
private
trimAndValidateHeaderValues(array<string|int, mixed> $values) : array<string|int, string>
Spaces and tabs ought to be excluded by parsers when extracting the field value from a header field.
header-field = field-name ":" OWS field-value OWS OWS = *( SP / HTAB )
Parameters
- $values : array<string|int, mixed>
-
Header values
Tags
Return values
array<string|int, string> —Trimmed header values