trait conditionable

internal  
 

Trait conditionable.

Adds when/unless helpers to allow fluent conditional logic.

Methods

when(mixed $value, callable $callback, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

unless(mixed $value, callable $callback, callable|null $default = null)

Apply the callback if the given "value" is falsy.

Details

at line 40
conditionable when(mixed $value, callable $callback, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

Parameters

mixed $value
callable $callback

fn($this, $value)

callable|null $default

fn($this, $value)

Return Value

conditionable

at line 62
conditionable unless(mixed $value, callable $callback, callable|null $default = null)

Apply the callback if the given "value" is falsy.

Parameters

mixed $value
callable $callback
callable|null $default

Return Value

conditionable