Documentation

MessageUtil
in package

FinalYes

Table of Contents

Methods

decodeJSON()  : mixed
decodeXML()  : mixed
decompress()  : string
Decompresses the message content according to the Content-Encoding header and returns the decompressed data
getContents()  : string
Read the message body's content, throws if the content could not be read from the message body
getCookiesFromHeader()  : array<string, string>|null
Attempts to extract and parse a cookie from a "Cookie" (user-agent) header
setContentLengthHeader()  : MessageInterface|RequestInterface|ResponseInterface|ServerRequestInterface
Sets a Content-Length header in the given message in case it does not exist and body size is not null
setContentTypeHeader()  : MessageInterface|RequestInterface|ResponseInterface|ServerRequestInterface
Tries to determine the content type from the given values and sets the Content-Type header accordingly, throws if no mime type could be guessed.
setCookie()  : ResponseInterface
Adds a Set-Cookie header to a ResponseInterface (convenience)
toJSON()  : string
Returns a JSON representation of an HTTP message.
toString()  : string
Returns the string representation of an HTTP message. (from Guzzle)
call_decompress_func()  : string

Methods

decodeJSON()

public static decodeJSON(MessageInterface $message[, bool|null $assoc = null ]) : mixed
Parameters
$message : MessageInterface
$assoc : bool|null = null
Tags
throws
JsonException

decodeXML()

public static decodeXML(MessageInterface $message[, bool|null $assoc = null ]) : mixed
Parameters
$message : MessageInterface
$assoc : bool|null = null

getContents()

Read the message body's content, throws if the content could not be read from the message body

public static getContents(MessageInterface $message) : string
Parameters
$message : MessageInterface
Tags
throws
RuntimeException
Return values
string

setContentLengthHeader()

Sets a Content-Length header in the given message in case it does not exist and body size is not null

public static setContentLengthHeader(MessageInterface $message) : MessageInterface|RequestInterface|ResponseInterface|ServerRequestInterface
Parameters
$message : MessageInterface
Return values
MessageInterface|RequestInterface|ResponseInterface|ServerRequestInterface

setContentTypeHeader()

Tries to determine the content type from the given values and sets the Content-Type header accordingly, throws if no mime type could be guessed.

public static setContentTypeHeader(MessageInterface $message[, string|null $filename = null ][, string|null $extension = null ]) : MessageInterface|RequestInterface|ResponseInterface|ServerRequestInterface
Parameters
$message : MessageInterface
$filename : string|null = null
$extension : string|null = null
Tags
throws
RuntimeException
Return values
MessageInterface|RequestInterface|ResponseInterface|ServerRequestInterface

setCookie()

Adds a Set-Cookie header to a ResponseInterface (convenience)

public static setCookie(ResponseInterface $message, string $name[, string|null $value = null ][, DateTimeInterface|DateInterval|int|null $expiry = null ][, string|null $domain = null ][, string|null $path = null ][, bool $secure = false ][, bool $httpOnly = false ][, string|null $sameSite = null ]) : ResponseInterface
Parameters
$message : ResponseInterface
$name : string
$value : string|null = null
$expiry : DateTimeInterface|DateInterval|int|null = null
$domain : string|null = null
$path : string|null = null
$secure : bool = false
$httpOnly : bool = false
$sameSite : string|null = null
Tags
see
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie
Return values
ResponseInterface

toJSON()

Returns a JSON representation of an HTTP message.

public static toJSON(MessageInterface $message[, bool|null $appendBody = null ]) : string
Parameters
$message : MessageInterface
$appendBody : bool|null = null
Return values
string

toString()

Returns the string representation of an HTTP message. (from Guzzle)

public static toString(MessageInterface $message[, bool|null $appendBody = null ]) : string
Parameters
$message : MessageInterface
$appendBody : bool|null = null
Return values
string

call_decompress_func()

protected static call_decompress_func(string $func, string $data) : string
Parameters
$func : string
$data : string
Tags
codeCoverageIgnore
Return values
string

        
On this page

Search results