Request
class Request implements Arrayable, Transient
Traits
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| protected string|null | $source | ||
| protected stdClass|null | $decodedSource |
Methods
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Get all or a subset of the arguments.
Retrieve an argument by its dot path.
Determine if the instance contains any of the given keys.
Apply the callback if the instance contains the given key.
Determine if the instance contains a non-empty value for the given key.
Determine if the instance contains an empty value for the given key.
Determine if the instance contains a non-empty value for any of the given keys.
Apply the callback if the instance contains a non-empty value for the given key.
Apply the callback if the instance contains a valid enum value for the given key.
Determine if the instance is missing a given key.
Apply the callback if the instance is missing the given key.
Determine if the given key is an empty string for "filled".
Retrieve data from the instance as a Stringable instance.
Retrieve data from the instance as a Stringable instance.
Retrieve data as a boolean value.
Retrieve data as an integer value.
Retrieve data as a float value.
Retrieve data clamped between min and max values.
Retrieve data from the instance as a Carbon instance.
Retrieve data from the instance as a CarbonInterval instance.
Retrieve data from the instance as an enum.
Retrieve data from the instance as an array of enums.
Retrieve data from the instance as an array.
Retrieve data from the instance as a collection.
Get a subset containing the provided keys with values from the instance data.
Get all of the data except for a specified array of items.
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Create a request for an MCP operation.
Get an argument from the request.
Get the request arguments as an array.
Validate the request arguments.
Get the authenticated user.
Get the request metadata.
Get the resource URI.
Get the original JSON-RPC message.
Preserve the wire shapes when forwarding nested tool arguments.
Determine whether the arguments or a nested value represent an object.
Set the request arguments.
Set the request metadata.
Set the resource URI.
Set the original JSON-RPC message.
Details
in
Conditionable at line 23
mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) truthy.
in
Conditionable at line 56
mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) falsy.
at line 50
array
all(mixed $keys = null)
Get all or a subset of the arguments.
at line 62
protected mixed
data(mixed $key = null, mixed $default = null)
Retrieve an argument by its dot path.
in
InteractsWithData at line 40
bool
exists(array|string $key)
Determine if the data contains a given key.
in
InteractsWithData at line 48
bool
has(array|string $key)
Determine if the data contains a given key.
in
InteractsWithData at line 67
bool
hasAny(array|string $keys)
Determine if the instance contains any of the given keys.
in
InteractsWithData at line 86
mixed
whenHas(string $key, callable $callback, callable|null $default = null)
Apply the callback if the instance contains the given key.
in
InteractsWithData at line 102
bool
filled(array|string $key)
Determine if the instance contains a non-empty value for the given key.
in
InteractsWithData at line 119
bool
isNotFilled(array|string $key)
Determine if the instance contains an empty value for the given key.
in
InteractsWithData at line 136
bool
anyFilled(array|string $keys)
Determine if the instance contains a non-empty value for any of the given keys.
in
InteractsWithData at line 160
mixed
whenFilled(string $key, callable $callback, callable|null $default = null)
Apply the callback if the instance contains a non-empty value for the given key.
in
InteractsWithData at line 185
mixed
whenEnum(string $key, string $enumClass, callable $callback, callable|null $default = null)
Apply the callback if the instance contains a valid enum value for the given key.
in
InteractsWithData at line 201
bool
missing(array|string $key)
Determine if the instance is missing a given key.
in
InteractsWithData at line 218
mixed
whenMissing(string $key, callable $callback, callable|null $default = null)
Apply the callback if the instance is missing the given key.
in
InteractsWithData at line 234
protected bool
isEmptyString(string $key)
Determine if the given key is an empty string for "filled".
in
InteractsWithData at line 246
Stringable
str(string $key, mixed $default = null, bool $strict = false)
Retrieve data from the instance as a Stringable instance.
in
InteractsWithData at line 256
Stringable
string(string $key, mixed $default = null, bool $strict = false)
Retrieve data from the instance as a Stringable instance.
When strict, values that are not strings, numbers, or Stringable objects return the default.
in
InteractsWithData at line 279
bool|null
boolean(string|null $key = null, Closure|bool|null $default = false, bool $strict = false)
Retrieve data as a boolean value.
Returns true when value is "1", "true", "on", and "yes". Otherwise, returns false. When strict, unrecognized or empty values return the default.
in
InteractsWithData at line 301
int|null
integer(string $key, Closure|int|null $default = 0, bool $strict = false)
Retrieve data as an integer value.
When strict, values that are not valid integers return the default.
in
InteractsWithData at line 328
float|null
float(string $key, Closure|float|null $default = 0.0, bool $strict = false)
Retrieve data as a float value.
When strict, values that are not valid numbers return the default.
in
InteractsWithData at line 347
int|float
clamp(string $key, int|float $min, int|float $max, int|float $default = 0)
Retrieve data clamped between min and max values.
in
InteractsWithData at line 365
CarbonInterface|null
date(string $key, string|null $format = null, UnitEnum|string|null $tz = null)
Retrieve data from the instance as a Carbon instance.
in
InteractsWithData at line 383
CarbonInterval|null
interval(string $key, Unit|string|null $unit = null)
Retrieve data from the instance as a CarbonInterval instance.
in
InteractsWithData at line 410
mixed
enum(string $key, string $enumClass, mixed $default = null)
Retrieve data from the instance as an enum.
in
InteractsWithData at line 427
array
enums(string $key, string $enumClass)
Retrieve data from the instance as an array of enums.
in
InteractsWithData at line 442
array
array(array|string|null $key = null)
Retrieve data from the instance as an array.
in
InteractsWithData at line 452
Collection
collect(array|string|null $key = null)
Retrieve data from the instance as a collection.
in
InteractsWithData at line 460
array
only(mixed $keys)
Get a subset containing the provided keys with values from the instance data.
in
InteractsWithData at line 482
array
except(mixed $keys)
Get all of the data except for a specified array of items.
in
Macroable at line 30
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 44
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 61
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 72
static void
flushMacros()
Flush the existing macros.
Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 83
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 108
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 37
__construct(array $arguments = [], array|null $meta = null, string|null $uri = null)
Create a request for an MCP operation.
at line 70
mixed
get(string $key, mixed $default = null)
Get an argument from the request.
at line 80
Request
merge(array $data)
Merge arguments into the request.
at line 92
array
toArray()
Get the request arguments as an array.
at line 107
array
validate(array $rules, array $messages = [], array $attributes = [])
Validate the request arguments.
at line 115
Authenticatable|null
user(string|null $guard = null)
Get the authenticated user.
at line 127
array|null
meta()
Get the request metadata.
at line 135
string|null
uri()
Get the resource URI.
at line 145
string|null
source()
| internal |
Get the original JSON-RPC message.
at line 155
string|null
sourceForArguments(string $key)
| internal |
Preserve the wire shapes when forwarding nested tool arguments.
at line 169
bool
isObject(string|null $key = null)
Determine whether the arguments or a nested value represent an object.
at line 201
void
setArguments(array $arguments)
Set the request arguments.
at line 211
void
setMeta(array|null $meta)
Set the request metadata.
at line 219
void
setUri(string|null $uri)
Set the resource URI.
at line 229
void
setSource(string|null $source)
| internal |
Set the original JSON-RPC message.