class When extends Mutator (View source)

If the condition is true, executes $then or $otherwise (if set).

Traits

Methods

__construct(mixed $condition, mixed $then, mixed $otherwise = null)

No description

mixed
__invoke(mixed $value)

Mutate the input value.

from  Mutator
static When
make(mixed $condition, mixed $then, mixed $otherwise = null)

No description

mixed
mutate(mixed $value)

Mutate the input value.

resolveComparator(mixed $comparator)

No description

array
resolveComparators(array $comparators)

No description

resolveMutator(mixed $mutator)

No description

array
resolveMutators(array $mutators)

No description

Details

__construct(mixed $condition, mixed $then, mixed $otherwise = null)

No description

Parameters

mixed $condition

The condition to check - If a callable is provided, it will be called with the value to check as the first argument.

mixed $then

The mutator to execute if the condition is true.

mixed $otherwise

The mutator to execute if the condition is false (optional).

final mixed __invoke(mixed $value)

Mutate the input value.

Parameters

mixed $value

Return Value

mixed

static When make(mixed $condition, mixed $then, mixed $otherwise = null)

No description

Parameters

mixed $condition

The condition to check - If a callable is provided, it will be called with the value to check as the first argument.

mixed $then

The mutator to execute if the condition is true.

mixed $otherwise

The mutator to execute if the condition is false (optional).

Return Value

When

mixed mutate(mixed $value)

Mutate the input value.

Parameters

mixed $value

Return Value

mixed

protected ComparatorInterface resolveComparator(mixed $comparator)

No description

Parameters

mixed $comparator

Return Value

ComparatorInterface

protected array resolveComparators(array $comparators)

No description

Parameters

array $comparators

Return Value

array

protected MutatorInterface resolveMutator(mixed $mutator)

No description

Parameters

mixed $mutator

Return Value

MutatorInterface

protected array resolveMutators(array $mutators)

No description

Parameters

array $mutators

Return Value

array