承接 theluk/php-condition-resolver 相关项目开发

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

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

theluk/php-condition-resolver

Composer 安装命令:

composer require theluk/php-condition-resolver

包简介

A small helper for defining conditions and matching them against some data

README 文档

README

A small helper for defining conditions and matching them against some data

Use

A condition resolver, that can uses some data array and a condition array to determine, if the data array matches the conditions.

a typical single condition looks like

array(
    "cmp" => "==",
    "left" => "value1",
    "right" => "value2"
)

as "left" and "right" keys you can use a path syntax, which will try to fetch the data from the main data object.

"left" => "My.Object.some_value"
"right" => "something"

$this->setConditions() method expects an array of many conditions arrays

array(
    array( "cmp" => ... ),
    array( "cmp" => ... )
)

you can also use two operators "or" and "and".

array(
    array("or" => array(
        array( "cmp" => ... ),
        array( "cmp" => ... )
    ))
) 

the operators can also be nested, the only important thing is that an operator syntax expects that the array must contain a single key, which is "or" or "and" and the value is again a list of conditions.

another example that should work

array(
    "or" => array(
        array(
            "and" => array(
                array( condition )
                array( condition )
                array(
                    "or" => array(
                     array ( ... )
                    )
                )
            )
        )
    )
)

Tests

run

phpunit ./src/ConditionResolverTest.php

统计信息

  • 总下载量: 21
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2016-06-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固