class Sequence extends Mutator (View source)

Combine multiple mutators into one. The output of the first mutator is passed to the second mutator, and so on.

Allowed mutators:

  • Any mutator implementing the Mutator interface
  • Any non-string callable
  • Any array of mutators

Traits

Methods

__construct(array $sequence = [])

No description

mixed
__invoke(mixed $value)

Mutate the input value.

from  Mutator
static Sequence
make(array $sequence = [])

No description

mixed
mutate(mixed $value)

Mutate the input value.

resolveMutator(mixed $mutator)

No description

array
resolveMutators(array $mutators)

No description

then(callable ...$sequence)

Add mutator(s) to the sequence.

when(callable|bool $condition, callable|array $then, callable|array $otherwise = null)

Add mutator(s) to the sequence that runs if a condition is met.

Details

__construct(array $sequence = [])

No description

Parameters

array $sequence

The sequence to execute.

final mixed __invoke(mixed $value)

Mutate the input value.

Parameters

mixed $value

Return Value

mixed

static Sequence make(array $sequence = [])

No description

Parameters

array $sequence

The sequence to execute.

Return Value

Sequence

mixed mutate(mixed $value)

Mutate the input value.

Parameters

mixed $value

Return Value

mixed

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

Sequence then(callable ...$sequence)

Add mutator(s) to the sequence.

Parameters

callable ...$sequence

The mutators to add.

Return Value

Sequence

Sequence when(callable|bool $condition, callable|array $then, callable|array $otherwise = null)

Add mutator(s) to the sequence that runs if a condition is met.

Parameters

callable|bool $condition

The condition to check.

callable|array $then

The mutator(s) to run if the condition is met.

callable|array $otherwise

The mutator(s) to run if the condition is not met.

Return Value

Sequence