ExpressionLanguage
in package
Allows to compile and evaluate expressions written in your own DSL.
Tags
Table of Contents
- $functions : mixed
- $cache : mixed
- $compiler : mixed
- $lexer : mixed
- $parser : mixed
- __construct() : mixed
- addFunction() : mixed
- compile() : string
- Compiles an expression source code.
- evaluate() : mixed
- Evaluate an expression.
- parse() : ParsedExpression
- Parses an expression.
- register() : mixed
- Registers a function.
- registerProvider() : mixed
- registerFunctions() : mixed
- getCompiler() : Compiler
- getLexer() : Lexer
- getParser() : Parser
Properties
$functions
protected
mixed
$functions
= []
$cache
private
mixed
$cache
$compiler
private
mixed
$compiler
$lexer
private
mixed
$lexer
$parser
private
mixed
$parser
Methods
__construct()
public
__construct([CacheItemPoolInterface $cache = null ][, array<string|int, ExpressionFunctionProviderInterface> $providers = [] ]) : mixed
Parameters
- $cache : CacheItemPoolInterface = null
- $providers : array<string|int, ExpressionFunctionProviderInterface> = []
Return values
mixed —addFunction()
public
addFunction(ExpressionFunction $function) : mixed
Parameters
- $function : ExpressionFunction
Return values
mixed —compile()
Compiles an expression source code.
public
compile(Expression|string $expression[, array<string|int, mixed> $names = [] ]) : string
Parameters
- $expression : Expression|string
-
The expression to compile
- $names : array<string|int, mixed> = []
-
An array of valid names
Return values
string —The compiled PHP source code
evaluate()
Evaluate an expression.
public
evaluate(Expression|string $expression[, array<string|int, mixed> $values = [] ]) : mixed
Parameters
- $expression : Expression|string
-
The expression to compile
- $values : array<string|int, mixed> = []
-
An array of values
Return values
mixed —The result of the evaluation of the expression
parse()
Parses an expression.
public
parse(Expression|string $expression, array<string|int, mixed> $names) : ParsedExpression
Parameters
- $expression : Expression|string
-
The expression to parse
- $names : array<string|int, mixed>
-
An array of valid names
Return values
ParsedExpression —A ParsedExpression instance
register()
Registers a function.
public
register(string $name, callable $compiler, callable $evaluator) : mixed
Parameters
- $name : string
-
The function name
- $compiler : callable
-
A callable able to compile the function
- $evaluator : callable
-
A callable able to evaluate the function
Tags
Return values
mixed —registerProvider()
public
registerProvider(ExpressionFunctionProviderInterface $provider) : mixed
Parameters
- $provider : ExpressionFunctionProviderInterface
Return values
mixed —registerFunctions()
protected
registerFunctions() : mixed
Return values
mixed —getCompiler()
private
getCompiler() : Compiler
Return values
Compiler —getLexer()
private
getLexer() : Lexer
Return values
Lexer —getParser()
private
getParser() : Parser