movisio/condition-parser
Composer 安装命令:
composer require movisio/condition-parser
包简介
Movisio Condition parser
README 文档
README
A simple condition parsing and evaluation library. Shunting-yard algorithm for parsing strings to expression trees that can ben evaluated later. Supports variables that can be set for each evaluation.
Installation:
composer require movisio/condition-parser
Example usage:
$expression = ConditionParser::parse('$deleted == 0 && $id > 1');
$conditionObject = new ArrayObject($userEntityData);
$can_be_deleted = $expression->evaluate($conditionObject)
Once parsed $expression object can be evaluated multiple times with different data.
The parse() method requires an object implementing the \ArrayAccess interface currently because we use it mostly with ORM entities that can implement it and because at the moment it is not possible to type-hint to array and \ArrayAccess at the same time.
v1.0.2
- tests for invalid inputs
- remove forbidden throw from __toString()
- add parsing of null
v1.0.1
- more unit tests
- fixes
- better handling of int and float constants including toString() not quoting numbers
- fix exception on empty($x) and toString() on UnaryOperator
v1.0.0 - initial release
统计信息
- 总下载量: 13.83k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2019-06-04