Serializer
extends AbstractSerializer
in package
FinalYes
Provides base functionality for request and response de/serialization strategies, including functionality for retrieving a line at a time from the message, splitting headers from the body, and serializing headers.
Table of Contents
Constants
Methods
- fromStream() : Response
- Parse a response from a stream.
- fromString() : Response
- Deserialize a response string to a response instance.
- toString() : string
- Create a string representation of a response.
- filterHeader() : string
- Filter a header name to wordcase
- getLine() : string
- Retrieve a single line from the stream.
- serializeHeaders() : string
- Serialize headers to string values.
- splitStream() : array<string|int, mixed>
- Split the stream into headers and body content.
- getStatusLine() : array<string|int, mixed>
- Retrieve the status line for the message.
Constants
CR
public
mixed
CR
= "\r"
EOL
public
mixed
EOL
= "\r\n"
LF
public
mixed
LF
= "\n"
Methods
fromStream()
Parse a response from a stream.
public
static fromStream(StreamInterface $stream) : Response
Parameters
- $stream : StreamInterface
Tags
Return values
ResponsefromString()
Deserialize a response string to a response instance.
public
static fromString(string $message) : Response
Parameters
- $message : string
Tags
Return values
ResponsetoString()
Create a string representation of a response.
public
static toString(ResponseInterface $response) : string
Parameters
- $response : ResponseInterface
Return values
stringfilterHeader()
Filter a header name to wordcase
protected
static filterHeader(string $header) : string
Parameters
- $header : string
Return values
stringgetLine()
Retrieve a single line from the stream.
protected
static getLine(StreamInterface $stream) : string
Retrieves a line from the stream; a line is defined as a sequence of characters ending in a CRLF sequence.
Parameters
- $stream : StreamInterface
Tags
Return values
stringserializeHeaders()
Serialize headers to string values.
protected
static serializeHeaders(array<string|int, mixed> $headers) : string
Parameters
- $headers : array<string|int, mixed>
Tags
Return values
stringsplitStream()
Split the stream into headers and body content.
protected
static splitStream(StreamInterface $stream) : array<string|int, mixed>
Returns an array containing two elements
- The first is an array of headers
- The second is a StreamInterface containing the body content
Parameters
- $stream : StreamInterface
Tags
Return values
array<string|int, mixed>getStatusLine()
Retrieve the status line for the message.
private
static getStatusLine(StreamInterface $stream) : array<string|int, mixed>
Parameters
- $stream : StreamInterface
Tags
Return values
array<string|int, mixed> —Array with three elements: 0 => version, 1 => status, 2 => reason