class ExprBuilder

This class builds an if expression.

Properties

$ifPart
$thenPart

Methods

__construct(NodeDefinition $node)

No description

$this
always(Closure $then = null)

Marks the expression as being always used.

$this
ifTrue(Closure $closure = null)

Sets a closure to use as tests.

$this
ifString()

Tests if the value is a string.

$this
ifNull()

Tests if the value is null.

ifEmpty()

Tests if the value is empty.

$this
ifArray()

Tests if the value is an array.

$this
ifInArray(array $array)

Tests if the value is in an array.

$this
ifNotInArray(array $array)

Tests if the value is not in an array.

$this
castToArray()

Transforms variables of any type into an array.

$this
then(Closure $closure)

Sets the closure to run if the test pass.

$this
thenEmptyArray()

Sets a closure returning an empty array.

$this
thenInvalid(string $message)

Sets a closure marking the value as invalid at validation time.

$this
thenUnset()

Sets a closure unsetting this key of the array at validation time.

NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition
end()

Returns the related node.

static array
buildExpressions(array $expressions)

Builds the expressions.

Details

at line line 28
__construct(NodeDefinition $node)

Parameters

NodeDefinition $node

at line line 38
$this always(Closure $then = null)

Marks the expression as being always used.

Parameters

Closure $then

Return Value

$this

at line line 56
$this ifTrue(Closure $closure = null)

Sets a closure to use as tests.

The default one tests if the value is true.

Parameters

Closure $closure

Return Value

$this

at line line 72
$this ifString()

Tests if the value is a string.

Return Value

$this

at line line 84
$this ifNull()

Tests if the value is null.

Return Value

$this

at line line 96
ExprBuilder ifEmpty()

Tests if the value is empty.

Return Value

ExprBuilder

at line line 108
$this ifArray()

Tests if the value is an array.

Return Value

$this

at line line 120
$this ifInArray(array $array)

Tests if the value is in an array.

Parameters

array $array

Return Value

$this

at line line 132
$this ifNotInArray(array $array)

Tests if the value is not in an array.

Parameters

array $array

Return Value

$this

at line line 144
$this castToArray()

Transforms variables of any type into an array.

Return Value

$this

at line line 157
$this then(Closure $closure)

Sets the closure to run if the test pass.

Parameters

Closure $closure

Return Value

$this

at line line 169
$this thenEmptyArray()

Sets a closure returning an empty array.

Return Value

$this

at line line 187
$this thenInvalid(string $message)

Sets a closure marking the value as invalid at validation time.

if you want to add the value of the node in your message just use a %s placeholder.

Parameters

string $message

Return Value

$this

Exceptions

InvalidArgumentException

at line line 201
$this thenUnset()

Sets a closure unsetting this key of the array at validation time.

Return Value

$this

Exceptions

UnsetKeyException

at line line 215
NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition end()

Returns the related node.

Return Value

NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition

Exceptions

RuntimeException

at line line 234
static array buildExpressions(array $expressions)

Builds the expressions.

Parameters

array $expressions An array of ExprBuilder instances to build

Return Value

array