jaspr/expression
最新稳定版本:1.1.4
Composer 安装命令:
composer require jaspr/expression
包简介
Rich expression builder allows create complex closure expression tree to filter array of objects
README 文档
README
Is a tool for creating expression tree to filter collection of objects. The main task is to be able filter object in array by their properties. Additionally, I will add SQLResolver to create WHERE filter for your query.
Example
<?php $obj1 = new \stdClass(); $obj1->field = 1; $obj2 = new \stdClass(); $obj2->field = 2; $arr = [$obj1, $obj2]; $expression = Ex::and( Ex::eq(Ex::field('field'), Ex::literal(1)), Ex::gt(Ex::field('field'), Ex::literal(0)) ); $resolver = new ClosureResolver(); $filter = $resolver->dispatch($expression); $result = array_filter($arr, $filter); Result
array(1) { [0] => class stdClass#410 (1) { public $field => int(1) } }
统计信息
- 总下载量: 13.71k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04