Aplus Framework Docs

Message
in package
implements MessageInterface

Class Message.

Tags
see
https://developer.mozilla.org/en-US/docs/Web/HTTP/Messages
see
https://datatracker.ietf.org/doc/html/rfc7231

Interfaces, Classes, Traits and Enums

MessageInterface
Interface MessageInterface.

Table of Contents

$body  : string
HTTP Message Body.
$cookies  : array<string|int, mixed>
HTTP Message Cookies.
$headers  : array<string|int, mixed>
HTTP Message Headers.
$jsonFlags  : int
$method  : string
HTTP Request Method.
$protocol  : string
HTTP Message Protocol.
$statusCode  : int
HTTP Response Status Code.
$url  : URL
HTTP Request URL.
__toString()  : string
getBody()  : string
Get the Message body.
getCookie()  : Cookie|null
Get a Cookie by name.
getCookies()  : array<string, Cookie>
Get all Cookies.
getHeader()  : string|null
getHeaderLine()  : string|null
getHeaderLines()  : array<int, string>
getHeaders()  : array<string, string>
getJsonFlags()  : int
Get JSON flags.
getProtocol()  : string
Get the HTTP protocol.
getStartLine()  : string
Get the Message Start-Line.
hasCookie()  : bool
Say if the Message has a Cookie.
hasHeader()  : bool
parseQualityValues()  : array<string, float>
setJsonFlags()  : static
Set JSON flags.
appendHeader()  : static
Append a Message header.
getMethod()  : string
Gets the HTTP Request Method.
getStatusCode()  : int
Get the status code.
getUrl()  : URL
Gets the requested URL.
isMethod()  : bool
isStatusCode()  : bool
parseContentType()  : string|null
removeCookie()  : static
Remove a Cookie by name.
removeCookies()  : static
Remove many Cookies by names.
removeHeader()  : static
Remove a header by name.
removeHeaders()  : static
Remove many headers by a list of headers.
setBody()  : static
Set the Message body.
setCookie()  : static
Set a new Cookie.
setCookies()  : static
Set a list of Cookies.
setHeader()  : static
Set a Message header.
setHeaders()  : static
Set a list of headers.
setMethod()  : static
Set the request method.
setProtocol()  : static
Set the HTTP protocol.
setStatusCode()  : static
setUrl()  : static
Set the Message URL.

Properties

$body

HTTP Message Body.

protected string $body

$cookies

HTTP Message Cookies.

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

$headers

HTTP Message Headers.

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

$jsonFlags

protected int $jsonFlags = \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE

$method

HTTP Request Method.

protected string $method

$protocol

HTTP Message Protocol.

protected string $protocol = \Framework\HTTP\Protocol::HTTP_1_1

$statusCode

HTTP Response Status Code.

protected int $statusCode

Methods

__toString()

public __toString() : string
Return values
string

getBody()

Get the Message body.

public getBody() : string
Return values
string

getCookie()

Get a Cookie by name.

public getCookie(string $name) : Cookie|null
Parameters
$name : string
Return values
Cookie|null

getCookies()

Get all Cookies.

public getCookies() : array<string, Cookie>
Return values
array<string, Cookie>

getHeader()

public getHeader(string $name) : string|null
Parameters
$name : string
Return values
string|null

getHeaderLine()

public getHeaderLine(string $name) : string|null
Parameters
$name : string
Return values
string|null

getHeaderLines()

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

getHeaders()

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

getJsonFlags()

Get JSON flags.

public getJsonFlags() : int
Tags
since
5.6
Return values
int

getProtocol()

Get the HTTP protocol.

public getProtocol() : string
Return values
string

getStartLine()

Get the Message Start-Line.

public getStartLine() : string
Tags
throws
BadMethodCallException

if $this is not an instance of RequestInterface or ResponseInterface

Return values
string

hasCookie()

Say if the Message has a Cookie.

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

Cookie name

Return values
bool

hasHeader()

public hasHeader(string $name[, string $value = null ]) : bool
Parameters
$name : string
$value : string = null
Return values
bool

setJsonFlags()

Set JSON flags.

public setJsonFlags(int $flags) : static
Parameters
$flags : int
Tags
since
5.6
Return values
static

getMethod()

Gets the HTTP Request Method.

protected getMethod() : string
Return values
string

$method One of: CONNECT, DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT, or TRACE

getStatusCode()

Get the status code.

protected getStatusCode() : int
Return values
int

getUrl()

Gets the requested URL.

protected getUrl() : URL
Return values
URL

isMethod()

protected isMethod(string $method) : bool
Parameters
$method : string
Tags
throws
InvalidArgumentException

for invalid method

Return values
bool

isStatusCode()

protected isStatusCode(int $code) : bool
Parameters
$code : int
Return values
bool

parseContentType()

protected parseContentType() : string|null
Return values
string|null

removeCookie()

Remove a Cookie by name.

protected removeCookie(string $name) : static
Parameters
$name : string
Return values
static

removeCookies()

Remove many Cookies by names.

protected removeCookies(array<int, string> $names) : static
Parameters
$names : array<int, string>
Return values
static

removeHeader()

Remove a header by name.

protected removeHeader(string $name) : static
Parameters
$name : string
Return values
static

removeHeaders()

Remove many headers by a list of headers.

protected removeHeaders() : static
Return values
static

setBody()

Set the Message body.

protected setBody(string $body) : static
Parameters
$body : string
Return values
static

setCookie()

Set a new Cookie.

protected setCookie(Cookie $cookie) : static
Parameters
$cookie : Cookie
Return values
static

setCookies()

Set a list of Cookies.

protected setCookies(array<int, Cookie$cookies) : static
Parameters
$cookies : array<int, Cookie>
Return values
static

setHeaders()

Set a list of headers.

protected setHeaders(array<string, string> $headers) : static
Parameters
$headers : array<string, string>
Return values
static

setMethod()

Set the request method.

protected setMethod(string $method) : static
Parameters
$method : string

One of: CONNECT, DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT, or TRACE

Tags
throws
InvalidArgumentException

for invalid method

Return values
static

setProtocol()

Set the HTTP protocol.

protected setProtocol(string $protocol) : static
Parameters
$protocol : string

HTTP/1.1, HTTP/2, etc

Return values
static

setStatusCode()

protected setStatusCode(int $code) : static
Parameters
$code : int
Return values
static

setUrl()

Set the Message URL.

protected setUrl(string|URL $url) : static
Parameters
$url : string|URL
Return values
static

Search results