ExprBuilder
in package
This class builds an if expression.
Tags
Table of Contents
Constants
- TYPE_ANY = 'any'
- TYPE_ARRAY = 'array'
- TYPE_NULL = 'null'
- TYPE_STRING = 'string'
Properties
- $allowedTypes : mixed
- $ifPart : mixed
- $thenPart : mixed
- $node : mixed
Methods
- __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.
Constants
TYPE_ANY
public
mixed
TYPE_ANY
= 'any'
TYPE_ARRAY
public
mixed
TYPE_ARRAY
= 'array'
TYPE_NULL
public
mixed
TYPE_NULL
= 'null'
TYPE_STRING
public
mixed
TYPE_STRING
= 'string'
Properties
$allowedTypes
public
mixed
$allowedTypes
$ifPart
public
mixed
$ifPart
$thenPart
public
mixed
$thenPart
$node
protected
mixed
$node
Methods
__construct()
public
__construct(NodeDefinition $node) : mixed
Parameters
- $node : NodeDefinition
always()
Marks the expression as being always used.
public
always([Closure|null $then = null ]) : $this
Parameters
- $then : Closure|null = null
Return values
$thisbuildExpressions()
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
$thisend()
Returns the related node.
public
end() : NodeDefinition|ArrayNodeDefinition|VariableNodeDefinition
Tags
Return values
NodeDefinition|ArrayNodeDefinition|VariableNodeDefinitionifArray()
Tests if the value is an array.
public
ifArray() : $this
Return values
$thisifEmpty()
Tests if the value is empty.
public
ifEmpty() : $this
Return values
$thisifInArray()
Tests if the value is in an array.
public
ifInArray(array<string|int, mixed> $array) : $this
Parameters
- $array : array<string|int, mixed>
Return values
$thisifNotInArray()
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
$thisifNull()
Tests if the value is null.
public
ifNull() : $this
Return values
$thisifString()
Tests if the value is a string.
public
ifString() : $this
Return values
$thisifTrue()
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
$thisthen()
Sets the closure to run if the test pass.
public
then(Closure $closure) : $this
Parameters
- $closure : Closure
Return values
$thisthenEmptyArray()
Sets a closure returning an empty array.
public
thenEmptyArray() : $this
Return values
$thisthenInvalid()
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
$thisthenUnset()
Sets a closure unsetting this key of the array at processing time.
public
thenUnset() : $this