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 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.
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.
in
Macroable at line 57
static bool
hasMacro(string $name)
Check if macro is registered.
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.
in
Macroable at line 78
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
at line 104
mixed
__call(string $method, array $parameters)
Dynamically pass a method to the underlying object.
at line 24
__construct(mixed $value)
Create a new optional instance.
at line 32
mixed
__get(string $key)
Dynamically access a property on the underlying object.
at line 44
bool
__isset(mixed $name)
Dynamically check a property exists on the underlying object.
at line 60
bool
offsetExists(mixed $key)
Determine if an item exists at an offset.
at line 68
mixed
offsetGet(mixed $key)
Get an item at a given offset.
at line 76
void
offsetSet(mixed $key, mixed $value)
Set the item at a given offset.
at line 86
void
offsetUnset(mixed $key)
Unset the item at a given offset.
at line 96
static void
flushState()
Flush all static state.