承接 jaspr/expression 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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.72k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-16