Documentation

Message
in package
implements MessageInterface, Stringable uses StringableTrait

AbstractYes

Phrity\WebSocket\Http\Message class.

Only used for handshake procedure.

Table of Contents

Interfaces

MessageInterface
HTTP messages consist of requests from a client to a server and responses from a server to a client. This interface defines the methods common to each.
Stringable

Properties

$headers  : array<string|int, mixed>
$version  : string

Methods

__toString()  : string
getAsArray()  : array<string|int, mixed>
getBody()  : StreamInterface
Not implemented, WebSocket only use headers.
getHeader()  : array<string|int, string>
Retrieves a message header value by the given case-insensitive name.
getHeaderLine()  : string
Retrieves a comma-separated string of the values for a single header.
getHeaders()  : array<string|int, array<string|int, string>>
Retrieves all message header values.
getProtocolVersion()  : string
Retrieves the HTTP protocol version as a string.
hasHeader()  : bool
Checks if a header exists by the given case-insensitive name.
withAddedHeader()  : static
Return an instance with the specified header appended with the given value.
withBody()  : static
Not implemented, WebSocket only use headers.
withHeader()  : static
Return an instance with the provided value replacing the specified header.
withoutHeader()  : static
Return an instance without the specified header.
withProtocolVersion()  : static
Return an instance with the specified HTTP protocol version.
stringable()  : string
handleHeader()  : void

Properties

$headers

protected array<string|int, mixed> $headers = []

$version

protected string $version = '1.1'

Methods

getAsArray()

public getAsArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

getHeader()

Retrieves a message header value by the given case-insensitive name.

public getHeader(string $name) : array<string|int, string>
Parameters
$name : string

Case-insensitive header field name.

Return values
array<string|int, string>

An array of string values as provided for the given header.

getHeaderLine()

Retrieves a comma-separated string of the values for a single header.

public getHeaderLine(string $name) : string
Parameters
$name : string

Case-insensitive header field name.

Return values
string

A string of values as provided for the given header.

getHeaders()

Retrieves all message header values.

public getHeaders() : array<string|int, array<string|int, string>>
Return values
array<string|int, array<string|int, string>>

Returns an associative array of the message's headers.

getProtocolVersion()

Retrieves the HTTP protocol version as a string.

public getProtocolVersion() : string
Return values
string

HTTP protocol version.

hasHeader()

Checks if a header exists by the given case-insensitive name.

public hasHeader(string $name) : bool
Parameters
$name : string

Case-insensitive header field name.

Return values
bool

Returns true if any header names match the given header.

withAddedHeader()

Return an instance with the specified header appended with the given value.

public withAddedHeader(string $name, string|array<string|int, string> $value) : static
Parameters
$name : string

Case-insensitive header field name to add.

$value : string|array<string|int, string>

Header value(s).

Tags
throws
InvalidArgumentException

for invalid header names.

throws
InvalidArgumentException

for invalid header values.

Return values
static

withHeader()

Return an instance with the provided value replacing the specified header.

public withHeader(string $name, string|array<string|int, string> $value) : static
Parameters
$name : string

Case-insensitive header field name.

$value : string|array<string|int, string>

Header value(s).

Tags
throws
InvalidArgumentException

for invalid header names or values.

Return values
static

withoutHeader()

Return an instance without the specified header.

public withoutHeader(string $name) : static
Parameters
$name : string

Case-insensitive header field name to remove.

Return values
static

withProtocolVersion()

Return an instance with the specified HTTP protocol version.

public withProtocolVersion(string $version) : static
Parameters
$version : string

HTTP protocol version

Return values
static

stringable()

protected stringable(string $format, mixed ...$values) : string
Parameters
$format : string
$values : mixed
Return values
string

handleHeader()

private handleHeader(string $name, mixed $value) : void
Parameters
$name : string
$value : mixed

        
On this page

Search results