Fr3nch13/CakePHP Utilities

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

CR  = "\r"
EOL  = "\r\n"
LF  = "\n"

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

Methods

fromString()

Deserialize a response string to a response instance.

public static fromString(string $message) : Response
Parameters
$message : string
Tags
throws
SerializationException

When errors occur parsing the message.

Return values
Response

filterHeader()

Filter a header name to wordcase

protected static filterHeader(string $header) : string
Parameters
$header : string
Return values
string

getLine()

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
throws
DeserializationException

If the sequence contains a CR or LF in isolation, or ends in a CR.

Return values
string

serializeHeaders()

Serialize headers to string values.

protected static serializeHeaders(array<string|int, mixed> $headers) : string
Parameters
$headers : array<string|int, mixed>
Tags
psalm-param

array<string, string[]> $headers

Return values
string

splitStream()

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
throws
DeserializationException

For invalid headers.

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
throws
SerializationException

If line is malformed.

Return values
array<string|int, mixed>

Array with three elements: 0 => version, 1 => status, 2 => reason


        
On this page

Search results