Snaju Inception Docs

WebRequest
in package

Table of Contents

$attributes  : Collection
$body  : array<string|int, mixed>
$cookies  : Collection
$domain  : mixed
$files  : array<string|int, mixed>
$headers  : Collection
$method  : mixed
$originIp  : mixed
$originPort  : mixed
$params  : Collection
$protocolVersion  : string
$rawBody  : string
$serverParams  : Collection
$uri  : Uri
__construct()  : mixed
__dangerouslyGetAll()  : array<string|int, mixed>
__dangerouslytoArray()  : array<string|int, mixed>
contains()  : bool
getAll()  : static
Return an instance that removes the specified derived request attribute.
getAttributes()  : array<string|int, mixed>
Retrieve attributes derived from the request.
getBody()  : StreamInterface
Gets the body of the message.
getCookieParams()  : array<string|int, mixed>
Retrieve cookies.
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.
getMethod()  : string
Retrieves the HTTP method of the request.
getParsedBody()  : null|array<string|int, mixed>|object
Retrieve any parameters provided in the request body.
getProtocolVersion()  : string
Retrieves the HTTP protocol version as a string.
getQueryParams()  : array<string|int, mixed>
Retrieve query string arguments.
getServerParams()  : array<string|int, mixed>
Retrieve server parameters.
getUploadedFiles()  : array<string|int, mixed>
Retrieve normalized file upload data.
getUri()  : UriInterface
Retrieves the URI instance.
hasHeader()  : bool
Checks if a header exists by the given case-insensitive name.
isMethod()  : bool
Helper method to determine if the request method matches the specified method.
toArray()  : array<string|int, mixed>
withMethod()  : static
Return an instance with the provided HTTP method.

Properties

$body

private array<string|int, mixed> $body = array()

$files

private array<string|int, mixed> $files = array()

$protocolVersion

private string $protocolVersion = ''

Methods

__construct()

public __construct() : mixed
Return values
mixed

__dangerouslyGetAll()

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

__dangerouslytoArray()

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

contains()

public contains(mixed ...$keys) : bool
Parameters
$keys : mixed
Return values
bool

getAll()

Return an instance that removes the specified derived request attribute.

public getAll() : static

This method allows removing a single derived request attribute as described in getAttributes().

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that removes the attribute.

Tags
see
getAttributes()
Return values
static

getAttributes()

Retrieve attributes derived from the request.

public getAttributes() : array<string|int, mixed>

The request "attributes" may be used to allow injection of any parameters derived from the request: e.g., the results of path match operations; the results of decrypting cookies; the results of deserializing non-form-encoded message bodies; etc. Attributes will be application and request specific, and CAN be mutable.

Return values
array<string|int, mixed>

Attributes derived from the request.

getBody()

Gets the body of the message.

public getBody() : StreamInterface
Return values
StreamInterface

Returns the body as a stream.

getCookieParams()

Retrieve cookies.

public getCookieParams() : array<string|int, mixed>

Retrieves cookies sent by the client to the server.

The data MUST be compatible with the structure of the $_COOKIE superglobal.

Return values
array<string|int, mixed>

getHeaderLine()

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

public getHeaderLine(string $name) : string

This method returns all of the header values of the given case-insensitive header name as a string concatenated together using a comma.

NOTE: Not all header values may be appropriately represented using comma concatenation. For such headers, use getHeader() instead and supply your own delimiter when concatenating.

If the header does not appear in the message, this method MUST return an empty string.

Parameters
$name : string

Case-insensitive header field name.

Return values
string

A string of values as provided for the given header concatenated together using a comma. If the header does not appear in the message, this method MUST return an empty string.

getHeaders()

Retrieves all message header values.

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

The keys represent the header name as it will be sent over the wire, and each value is an array of strings associated with the header.

// Represent the headers as a string
foreach ($message->getHeaders() as $name => $values) {
    echo $name . ": " . implode(", ", $values);
}

// Emit headers iteratively:
foreach ($message->getHeaders() as $name => $values) {
    foreach ($values as $value) {
        header(sprintf('%s: %s', $name, $value), false);
    }
}

While header names are not case-sensitive, getHeaders() will preserve the exact case in which headers were originally specified.

Return values
array<string|int, array<string|int, string>>

Returns an associative array of the message's headers. Each key MUST be a header name, and each value MUST be an array of strings for that header.

getMethod()

Retrieves the HTTP method of the request.

public getMethod() : string
Return values
string

Returns the request method.

getParsedBody()

Retrieve any parameters provided in the request body.

public getParsedBody() : null|array<string|int, mixed>|object

If the request Content-Type is either application/x-www-form-urlencoded or multipart/form-data, and the request method is POST, this method MUST return the contents of $_POST.

Otherwise, this method may return any results of deserializing the request body content; as parsing returns structured content, the potential types MUST be arrays or objects only. A null value indicates the absence of body content.

Return values
null|array<string|int, mixed>|object

The deserialized body parameters, if any. These will typically be an array or object.

getProtocolVersion()

Retrieves the HTTP protocol version as a string.

public getProtocolVersion() : string

The string MUST contain only the HTTP version number (e.g., "1.1", "1.0").

Return values
string

HTTP protocol version.

getQueryParams()

Retrieve query string arguments.

public getQueryParams() : array<string|int, mixed>

Retrieves the deserialized query string arguments, if any.

Note: the query params might not be in sync with the URI or server params. If you need to ensure you are only getting the original values, you may need to parse the query string from getUri()->getQuery() or from the QUERY_STRING server param.

Return values
array<string|int, mixed>

getServerParams()

Retrieve server parameters.

public getServerParams() : array<string|int, mixed>

Retrieves data related to the incoming request environment, typically derived from PHP's $_SERVER superglobal. The data IS NOT REQUIRED to originate from $_SERVER.

Return values
array<string|int, mixed>

getUploadedFiles()

Retrieve normalized file upload data.

public getUploadedFiles() : array<string|int, mixed>

This method returns upload metadata in a normalized tree, with each leaf an instance of Psr\Http\Message\UploadedFileInterface.

These values MAY be prepared from $_FILES or the message body during instantiation, or MAY be injected via withUploadedFiles().

Return values
array<string|int, mixed>

An array tree of UploadedFileInterface instances; an empty array MUST be returned if no data is present.

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 name using a case-insensitive string comparison. Returns false if no matching header name is found in the message.

isMethod()

Helper method to determine if the request method matches the specified method.

public isMethod(string $method) : bool
Parameters
$method : string
Return values
bool

toArray()

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

withMethod()

Return an instance with the provided HTTP method.

public withMethod(string $method) : static

While HTTP method names are typically all uppercase characters, HTTP method names are case-sensitive and thus implementations SHOULD NOT modify the given string.

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the changed request method.

Parameters
$method : string

Case-sensitive method.

Tags
throws
InvalidArgumentException

for invalid HTTP methods.

Return values
static

Search results