Optional
class Optional implements ArrayAccess
Traits
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| protected mixed | $value | The underlying object. |
Methods
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically pass a method to the underlying object.
Create a new optional instance.
Dynamically access a property on the underlying object.
Dynamically check a property exists on the underlying object.
Determine if an item exists at an offset.
Get an item at a given offset.
Set the item at a given offset.
Unset the item at a given offset.
Flush all static state.
Details
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.
at line 109
mixed
__call(string $method, array $parameters)
Dynamically pass a method to the underlying object.
at line 29
__construct(mixed $value)
Create a new optional instance.
at line 37
mixed
__get(string $key)
Dynamically access a property on the underlying object.
at line 49
bool
__isset(mixed $name)
Dynamically check a property exists on the underlying object.
at line 65
bool
offsetExists(mixed $offset)
Determine if an item exists at an offset.
at line 73
mixed
offsetGet(mixed $offset)
Get an item at a given offset.
at line 81
void
offsetSet(mixed $offset, mixed $value)
Set the item at a given offset.
at line 91
void
offsetUnset(mixed $offset)
Unset the item at a given offset.
at line 101
static void
flushState()
Flush all static state.