class Optional implements ArrayAccess (View source)

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected mixed $value

The underlying object.

Methods

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

Register a custom macro.

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

Mix another object into the class.

static bool
hasMacro(string $name)

Checks 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 pass a method to the underlying object.

void
__construct(mixed $value)

Create a new optional instance.

mixed
__get(string $key)

Dynamically access a property on the underlying object.

bool
__isset(mixed $name)

Dynamically check a property exists on the underlying object.

bool
offsetExists(mixed $key)

Determine if an item exists at an offset.

mixed
offsetGet(mixed $key)

Get an item at a given offset.

void
offsetSet(mixed $key, mixed $value)

Set the item at a given offset.

void
offsetUnset(string $key)

Unset the item at a given offset.

Details

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

Register a custom macro.

Parameters

string $name
object|callable $macro

Return Value

void

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

Mix another object into the class.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

static void flushMacros()

Flush the existing macros.

Return Value

void

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

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

mixed __call(string $method, array $parameters)

Dynamically pass a method to the underlying object.

Parameters

string $method
array $parameters

Return Value

mixed

void __construct(mixed $value)

Create a new optional instance.

Parameters

mixed $value

Return Value

void

mixed __get(string $key)

Dynamically access a property on the underlying object.

Parameters

string $key

Return Value

mixed

bool __isset(mixed $name)

Dynamically check a property exists on the underlying object.

Parameters

mixed $name

Return Value

bool

bool offsetExists(mixed $key)

Determine if an item exists at an offset.

Parameters

mixed $key

Return Value

bool

mixed offsetGet(mixed $key)

Get an item at a given offset.

Parameters

mixed $key

Return Value

mixed

void offsetSet(mixed $key, mixed $value)

Set the item at a given offset.

Parameters

mixed $key
mixed $value

Return Value

void

void offsetUnset(string $key)

Unset the item at a given offset.

Parameters

string $key

Return Value

void