class Set extends Mutator (View source)

Set a value in an array or object by key using dot notation.

If the key is an array, it will be treated as a path to the value.

Ported and adapted from illuminate/collections helper data_set.

Methods

__construct(array|int|string $key, mixed $value, bool $overwrite = true)

No description

mixed
__invoke(mixed $value)

Mutate the input value.

from  Mutator
static Set
make(array|int|string $key, mixed $value, bool $overwrite = true)

No description

mixed
mutate(mixed $value)

Mutate the input value.

Details

__construct(array|int|string $key, mixed $value, bool $overwrite = true)

No description

Parameters

array|int|string $key

The key to set

mixed $value

The value to set

bool $overwrite

Whether to overwrite existing values (default: true)

final mixed __invoke(mixed $value)

Mutate the input value.

Parameters

mixed $value

Return Value

mixed

static Set make(array|int|string $key, mixed $value, bool $overwrite = true)

No description

Parameters

array|int|string $key

The key to set

mixed $value

The value to set

bool $overwrite

Whether to overwrite existing values (default: true)

Return Value

Set

mixed mutate(mixed $value)

Mutate the input value.

Parameters

mixed $value

Return Value

mixed