Documentation

ExprBuilder
in package

This class builds an if expression.

Tags
template
author

Johannes M. Schmitt schmittjoh@gmail.com

Christophe Coevoet stof@notk.org

Table of Contents

Constants

TYPE_ANY  : mixed = 'any'
TYPE_ARRAY  : mixed = 'array'
TYPE_BACKED_ENUM  : mixed = 'backed-enum'
TYPE_BOOL  : mixed = 'bool'
TYPE_INT  : mixed = 'int'
TYPE_NULL  : mixed = 'null'
TYPE_STRING  : mixed = 'string'

Properties

$allowedTypes  : string
$ifPart  : Closure|null
$thenPart  : Closure|null
$node  : NodeDefinition

Methods

__construct()  : mixed
always()  : $this
Marks the expression as being always used.
buildExpressions()  : array<string|int, Closure>
Builds the expressions.
castToArray()  : $this
Transforms variables of any type into an array.
end()  : T
Returns the related node.
ifArray()  : $this
Tests if the value is an array.
ifEmpty()  : $this
Tests if the value is empty.
ifFalse()  : $this
Sets a closure to use as tests.
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_BACKED_ENUM

public mixed TYPE_BACKED_ENUM = 'backed-enum'

Properties

Methods

__construct()

public __construct(T $node) : mixed
Parameters
$node : T

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|Closure> $expressions) : array<string|int, Closure>
Parameters
$expressions : array<string|int, ExprBuilder|Closure>
Return values
array<string|int, Closure>

castToArray()

Transforms variables of any type into an array.

public castToArray() : $this
Return values
$this

end()

Returns the related node.

public end() : T
Tags
throws
RuntimeException
Return values
T

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

ifFalse()

Sets a closure to use as tests.

public ifFalse([Closure|null $closure = null ]) : $this

The default one tests if the value is false.

Parameters
$closure : Closure|null = null
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
throws
InvalidArgumentException
Return values
$this

thenUnset()

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

public thenUnset() : $this
Tags
throws
UnsetKeyException
Return values
$this
On this page

Search results