2017 © Pedro Peláez
 

library php-condition-resolver

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

image

theluk/php-condition-resolver

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

  • Friday, July 15, 2016
  • by theluk
  • Repository
  • 2 Watchers
  • 1 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

php-condition-resolver

A small helper for defining conditions and matching them against some data, (*1)

Use

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

a typical single condition looks like, (*3)

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., (*4)

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

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

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

you can also use two operators "or" and "and"., (*6)

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., (*7)

another example that should work, (*8)

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

Tests

run, (*9)

phpunit ./src/ConditionResolverTest.php

The Versions

15/07 2016

dev-master

9999999-dev https://github.com/theluk/php-condition-resolver

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

  Sources   Download

The Requires

  • php >=5.3.0

 

The Development Requires

by Lukas Klinzing

php conditions

09/06 2016

v0.1.0

0.1.0.0 https://github.com/theluk/php-condition-resolver

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

  Sources   Download

The Requires

  • php >=5.3.0

 

The Development Requires

by Lukas Klinzing

php conditions