ExprBuilder
in package
This class builds an if expression.
Tags
Table of Contents
- $ifPart : mixed
- $thenPart : mixed
- $node : mixed
- __construct() : mixed
- always() : $this
- Marks the expression as being always used.
- buildExpressions() : array<string|int, mixed>
- Builds the expressions.
- castToArray() : $this
- Transforms variables of any type into an array.
- end() : NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition
- Returns the related node.
- ifArray() : $this
- Tests if the value is an array.
- ifEmpty() : $this
- Tests if the value is empty.
- ifInArray() : $this
- Tests if the value is in an array.
- ifNotInArray() : $this
- Tests if the value is not in an array.
- ifNull() : $this
- Tests if the value is null.
- ifString() : $this
- Tests if the value is a string.
- ifTrue() : $this
- Sets a closure to use as tests.
- then() : $this
- Sets the closure to run if the test pass.
- thenEmptyArray() : $this
- Sets a closure returning an empty array.
- thenInvalid() : $this
- Sets a closure marking the value as invalid at processing time.
- thenUnset() : $this
- Sets a closure unsetting this key of the array at processing time.
Properties
$ifPart
public
mixed
$ifPart
$thenPart
public
mixed
$thenPart
$node
protected
mixed
$node
Methods
__construct()
public
__construct(NodeDefinition $node) : mixed
Parameters
- $node : NodeDefinition
Return values
mixed —always()
Marks the expression as being always used.
public
always([Closure|null $then = null ]) : $this
Parameters
- $then : Closure|null = null
Return values
$this —buildExpressions()
Builds the expressions.
public
static buildExpressions(array<string|int, ExprBuilder> $expressions) : array<string|int, mixed>
Parameters
- $expressions : array<string|int, ExprBuilder>
-
An array of ExprBuilder instances to build
Return values
array<string|int, mixed> —castToArray()
Transforms variables of any type into an array.
public
castToArray() : $this
Return values
$this —end()
Returns the related node.
public
end() : NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition
Tags
Return values
NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition —ifArray()
Tests if the value is an array.
public
ifArray() : $this
Return values
$this —ifEmpty()
Tests if the value is empty.
public
ifEmpty() : $this
Return values
$this —ifInArray()
Tests if the value is in an array.
public
ifInArray(array<string|int, mixed> $array) : $this
Parameters
- $array : array<string|int, mixed>
Return values
$this —ifNotInArray()
Tests if the value is not in an array.
public
ifNotInArray(array<string|int, mixed> $array) : $this
Parameters
- $array : array<string|int, mixed>
Return values
$this —ifNull()
Tests if the value is null.
public
ifNull() : $this
Return values
$this —ifString()
Tests if the value is a string.
public
ifString() : $this
Return values
$this —ifTrue()
Sets a closure to use as tests.
public
ifTrue([Closure|null $closure = null ]) : $this
The default one tests if the value is true.
Parameters
- $closure : Closure|null = null
Return values
$this —then()
Sets the closure to run if the test pass.
public
then(Closure $closure) : $this
Parameters
- $closure : Closure
Return values
$this —thenEmptyArray()
Sets a closure returning an empty array.
public
thenEmptyArray() : $this
Return values
$this —thenInvalid()
Sets a closure marking the value as invalid at processing time.
public
thenInvalid(string $message) : $this
if you want to add the value of the node in your message just use a %s placeholder.
Parameters
- $message : string
Tags
Return values
$this —thenUnset()
Sets a closure unsetting this key of the array at processing time.
public
thenUnset() : $this