class Request implements Arrayable, ArrayAccess

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable

Methods

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.

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.

array
all(mixed $keys = null)

Get all or a subset of the tool arguments.

mixed
data(mixed $key = null, mixed $default = null)

Get a tool argument or all arguments.

bool
exists(array|string $key)

Determine if the data contains a given key.

bool
has(array|string $key)

Determine if the data contains a given key.

bool
hasAny(array|string $keys)

Determine if the instance contains any of the given keys.

mixed
whenHas(string $key, callable $callback, callable|null $default = null)

Apply the callback if the instance contains the given key.

bool
filled(array|string $key)

Determine if the instance contains a non-empty value for the given key.

bool
isNotFilled(array|string $key)

Determine if the instance contains an empty value for the given key.

bool
anyFilled(array|string $keys)

Determine if the instance contains a non-empty value for any of the given keys.

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.

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.

bool
missing(array|string $key)

Determine if the instance is missing a given key.

mixed
whenMissing(string $key, callable $callback, callable|null $default = null)

Apply the callback if the instance is missing the given key.

bool
isEmptyString(string $key)

Determine if the given key is an empty string for "filled".

str(string $key, mixed $default = null, bool $strict = false)

Retrieve data from the instance as a Stringable instance.

string(string $key, mixed $default = null, bool $strict = false)

Retrieve data from the instance as a Stringable instance.

bool|null
boolean(string|null $key = null, Closure|bool|null $default = false, bool $strict = false)

Retrieve data as a boolean value.

int|null
integer(string $key, Closure|int|null $default = 0, bool $strict = false)

Retrieve data as an integer value.

float|null
float(string $key, Closure|float|null $default = 0.0, bool $strict = false)

Retrieve data as a float value.

int|float
clamp(string $key, int|float $min, int|float $max, int|float $default = 0)

Retrieve data clamped between min and max values.

CarbonInterface|null
date(string $key, string|null $format = null, UnitEnum|string|null $tz = null)

Retrieve data from the instance as a Carbon instance.

CarbonInterval|null
interval(string $key, Unit|string|null $unit = null)

Retrieve data from the instance as a CarbonInterval instance.

mixed
enum(string $key, string $enumClass, mixed $default = null)

Retrieve data from the instance as an enum.

array
enums(string $key, string $enumClass)

Retrieve data from the instance as an array of enums.

array
array(array|string|null $key = null)

Retrieve data from the instance as an array.

collect(array|string|null $key = null)

Retrieve data from the instance as a collection.

array
only(mixed $keys)

Get a subset containing the provided keys with values from the instance data.

array
except(mixed $keys)

Get all of the data except for a specified array of items.

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(array $arguments = [], string|null $toolCallId = null, string|null $toolInvocationId = null)

Create a tool request with its arguments and execution identifiers.

string|null
toolCallId()

Get the stable provider tool-call ID, usable as an external idempotency key.

string|null
toolInvocationId()

Get the ID correlating this execution with the tool invocation events dispatched around it.

array
validate(array $rules, array $messages = [], array $attributes = [])

Validate the tool arguments against the given rules.

array
toArray()

Get the tool arguments as an array.

bool
offsetExists(mixed $offset)

Determine if an item exists at an offset.

mixed
offsetGet(mixed $offset)

Get an item at a given offset.

void
offsetSet(mixed $offset, mixed $value)

Set the item at a given offset.

void
offsetUnset(mixed $offset)

Unset the item at a given offset.

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.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

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.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

at line 68
array all(mixed $keys = null)

Get all or a subset of the tool arguments.

Parameters

mixed $keys

Return Value

array

at line 83
protected mixed data(mixed $key = null, mixed $default = null)

Get a tool argument or all arguments.

Parameters

mixed $key
mixed $default

Return Value

mixed

in InteractsWithData at line 40
bool exists(array|string $key)

Determine if the data contains a given key.

Parameters

array|string $key

Return Value

bool

in InteractsWithData at line 48
bool has(array|string $key)

Determine if the data contains a given key.

Parameters

array|string $key

Return Value

bool

in InteractsWithData at line 67
bool hasAny(array|string $keys)

Determine if the instance contains any of the given keys.

Parameters

array|string $keys

Return Value

bool

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.

Parameters

string $key
callable $callback
callable|null $default

Return Value

mixed

in InteractsWithData at line 102
bool filled(array|string $key)

Determine if the instance contains a non-empty value for the given key.

Parameters

array|string $key

Return Value

bool

in InteractsWithData at line 119
bool isNotFilled(array|string $key)

Determine if the instance contains an empty value for the given key.

Parameters

array|string $key

Return Value

bool

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.

Parameters

array|string $keys

Return Value

bool

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.

Parameters

string $key
callable $callback
callable|null $default

Return Value

mixed

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.

Parameters

string $key
string $enumClass
callable $callback
callable|null $default

Return Value

mixed

in InteractsWithData at line 201
bool missing(array|string $key)

Determine if the instance is missing a given key.

Parameters

array|string $key

Return Value

bool

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.

Parameters

string $key
callable $callback
callable|null $default

Return Value

mixed

in InteractsWithData at line 234
protected bool isEmptyString(string $key)

Determine if the given key is an empty string for "filled".

Parameters

string $key

Return Value

bool

in InteractsWithData at line 246
Stringable str(string $key, mixed $default = null, bool $strict = false)

Retrieve data from the instance as a Stringable instance.

Parameters

string $key
mixed $default
bool $strict

Return Value

Stringable

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.

Parameters

string $key
mixed $default
bool $strict

Return Value

Stringable

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.

Parameters

string|null $key
Closure|bool|null $default
bool $strict

Return Value

bool|null

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.

Parameters

string $key
Closure|int|null $default
bool $strict

Return Value

int|null

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.

Parameters

string $key
Closure|float|null $default
bool $strict

Return Value

float|null

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.

Parameters

string $key
int|float $min
int|float $max
int|float $default

Return Value

int|float

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.

Parameters

string $key
string|null $format
UnitEnum|string|null $tz

Return Value

CarbonInterface|null

Exceptions

InvalidFormatException

in InteractsWithData at line 383
CarbonInterval|null interval(string $key, Unit|string|null $unit = null)

Retrieve data from the instance as a CarbonInterval instance.

Parameters

string $key
Unit|string|null $unit

Return Value

CarbonInterval|null

in InteractsWithData at line 410
mixed enum(string $key, string $enumClass, mixed $default = null)

Retrieve data from the instance as an enum.

Parameters

string $key
string $enumClass
mixed $default

Return Value

mixed

in InteractsWithData at line 427
array enums(string $key, string $enumClass)

Retrieve data from the instance as an array of enums.

Parameters

string $key
string $enumClass

Return Value

array

in InteractsWithData at line 442
array array(array|string|null $key = null)

Retrieve data from the instance as an array.

Parameters

array|string|null $key

Return Value

array

in InteractsWithData at line 452
Collection collect(array|string|null $key = null)

Retrieve data from the instance as a collection.

Parameters

array|string|null $key

Return Value

Collection

in InteractsWithData at line 460
array only(mixed $keys)

Get a subset containing the provided keys with values from the instance data.

Parameters

mixed $keys

Return Value

array

in InteractsWithData at line 482
array except(mixed $keys)

Get all of the data except for a specified array of items.

Parameters

mixed $keys

Return Value

array

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.

Parameters

string $name
callable|object $macro

Return Value

void

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.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

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

Check if macro is registered.

Parameters

string $name

Return Value

bool

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.

Return Value

void

in Macroable at line 83
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 108
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 24
__construct(array $arguments = [], string|null $toolCallId = null, string|null $toolInvocationId = null)

Create a tool request with its arguments and execution identifiers.

Parameters

array $arguments
string|null $toolCallId
string|null $toolInvocationId

at line 34
string|null toolCallId()

Get the stable provider tool-call ID, usable as an external idempotency key.

Return Value

string|null

at line 42
string|null toolInvocationId()

Get the ID correlating this execution with the tool invocation events dispatched around it.

Return Value

string|null

at line 57
array validate(array $rules, array $messages = [], array $attributes = [])

Validate the tool arguments against the given rules.

Parameters

array $rules
array $messages
array $attributes

Return Value

array

Exceptions

ValidationException

at line 93
array toArray()

Get the tool arguments as an array.

Return Value

array

at line 101
bool offsetExists(mixed $offset)

Determine if an item exists at an offset.

Parameters

mixed $offset

Return Value

bool

at line 109
mixed offsetGet(mixed $offset)

Get an item at a given offset.

Parameters

mixed $offset

Return Value

mixed

at line 117
void offsetSet(mixed $offset, mixed $value)

Set the item at a given offset.

Parameters

mixed $offset
mixed $value

Return Value

void

at line 129
void offsetUnset(mixed $offset)

Unset the item at a given offset.

Parameters

mixed $offset

Return Value

void