class Request implements ArrayAccess

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected array $data

The decoded payload for the request.

protected array $attributes

The attribute data passed when building the PendingRequest.

Methods

static void
macro(string $name, callable|object $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Check if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

__construct(RequestInterface $request)

Create a new request instance.

string
method()

Get the request method.

string
url()

Get the URL of the request.

Uri
uri()

Get the request URI as a URI instance.

bool
hasHeader(string $key, mixed $value = null)

Determine if the request has a given header.

bool
hasHeaders(array|string $headers)

Determine if the request has the given headers.

array
header(string $key)

Get the values for the header with the given name.

array
headers()

Get the request headers.

string
body()

Get the body of the request.

bool
hasFile(string $name, string|null $value = null, string|null $filename = null)

Determine if the request contains the given file.

array
data()

Get the request's data (form parameters or JSON).

array
parameters()

Get the request's form parameters.

array
json()

Get the JSON decoded body of the request.

bool
isForm()

Determine if the request is simple form data.

bool
isJson()

Determine if the request is JSON.

bool
isMultipart()

Determine if the request is multipart.

withData(array $data)

Set the decoded data on the request.

array
query()

No description

withQuery(array $query = [])

No description

withoutQuery(array $keys = [])

No description

array
attributes()

Get the attribute data from the request.

setRequestAttributes(array $attributes)

Set the request's attribute data.

RequestInterface
toPsrRequest()

Get the underlying PSR compliant request instance.

bool
offsetExists(string $offset)

Determine if the given offset exists.

mixed
offsetGet(string $offset)

Get the value for a given offset.

void
offsetSet(string $offset, mixed $value)

Set the value at the given offset.

void
offsetUnset(string $offset)

Unset the value at the given offset.

static void
flushState()

Flush all static state.

Details

in Macroable at line 28
static void macro(string $name, callable|object $macro)

Register a custom macro.

Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.

Parameters

string $name
callable|object $macro

Return Value

void

in Macroable at line 41
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 57
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 68
static void flushMacros()

Flush the existing macros.

Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.

Return Value

void

in Macroable at line 78
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line 103
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 32
__construct(RequestInterface $request)

Create a new request instance.

Parameters

RequestInterface $request

at line 39
string method()

Get the request method.

Return Value

string

at line 47
string url()

Get the URL of the request.

Return Value

string

at line 55
Uri uri()

Get the request URI as a URI instance.

Return Value

Uri

at line 63
bool hasHeader(string $key, mixed $value = null)

Determine if the request has a given header.

Parameters

string $key
mixed $value

Return Value

bool

at line 83
bool hasHeaders(array|string $headers)

Determine if the request has the given headers.

Parameters

array|string $headers

Return Value

bool

at line 101
array header(string $key)

Get the values for the header with the given name.

Parameters

string $key

Return Value

array

at line 109
array headers()

Get the request headers.

Return Value

array

at line 117
string body()

Get the body of the request.

Return Value

string

at line 125
bool hasFile(string $name, string|null $value = null, string|null $filename = null)

Determine if the request contains the given file.

Parameters

string $name
string|null $value
string|null $filename

Return Value

bool

at line 141
array data()

Get the request's data (form parameters or JSON).

Return Value

array

at line 156
protected array parameters()

Get the request's form parameters.

Return Value

array

at line 170
protected array json()

Get the JSON decoded body of the request.

Return Value

array

at line 182
bool isForm()

Determine if the request is simple form data.

Return Value

bool

at line 190
bool isJson()

Determine if the request is JSON.

Return Value

bool

at line 199
bool isMultipart()

Determine if the request is multipart.

Return Value

bool

at line 208
Request withData(array $data)

Set the decoded data on the request.

Parameters

array $data

Return Value

Request

at line 215
array query()

No description

Return Value

array

at line 222
Request withQuery(array $query = [])

No description

Parameters

array $query

Return Value

Request

at line 231
Request withoutQuery(array $keys = [])

No description

Parameters

array $keys

Return Value

Request

at line 245
array attributes()

Get the attribute data from the request.

Return Value

array

at line 253
Request setRequestAttributes(array $attributes)

Set the request's attribute data.

Parameters

array $attributes

Return Value

Request

at line 263
RequestInterface toPsrRequest()

Get the underlying PSR compliant request instance.

Return Value

RequestInterface

at line 273
bool offsetExists(string $offset)

Determine if the given offset exists.

Parameters

string $offset

Return Value

bool

at line 283
mixed offsetGet(string $offset)

Get the value for a given offset.

Parameters

string $offset

Return Value

mixed

at line 295
void offsetSet(string $offset, mixed $value)

Set the value at the given offset.

Parameters

string $offset
mixed $value

Return Value

void

Exceptions

LogicException

at line 307
void offsetUnset(string $offset)

Unset the value at the given offset.

Parameters

string $offset

Return Value

void

Exceptions

LogicException

at line 315
static void flushState()

Flush all static state.

Return Value

void