PHPackages                             kmuenkel/rule-evaluator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kmuenkel/rule-evaluator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kmuenkel/rule-evaluator
=======================

Check a given data-set against a recursive rule-set

v1.0.0(6y ago)02931MITPHPPHP &gt;=7.0.0

Since Feb 4Pushed 4y ago1 watchersCompare

[ Source](https://github.com/kmuenkel/rule-evaluator)[ Packagist](https://packagist.org/packages/kmuenkel/rule-evaluator)[ RSS](/packages/kmuenkel-rule-evaluator/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (1)

Rule Evaluator
==============

[](#rule-evaluator)

Check a given data-set against a recursive rule-set

You begin with a config array that may or may not originate from a database. There are only three dataponts to each "rule".

- First Value
- Comparison operator
- Second Value

The key name for the first and second values indicates the nature of these values.

- `reference1/reference2` indicates that the content will posses a dot-notation reference to a datapoint within the array of data being evaluated.
- `value1/value2` will expect to hold a static value that should be taken at face value.
- `child1/child2` means the "value" would be the boolean result of a nested "rule".

Through the dot-notation references and support of 'child' rules, both the data and the conditions support infinite complexity. But being a flat 3-point 'rule' record, this makes it conducive to the rules being managed through a database instead of a config file. While such a parser doesn't exist yet, all you'd need to do is ensure that your `DBParser` class implements the same `Parser` interface as the current `ConfigParser`.

The comparison operators, keyed as `comparator`, may be any of the following:

- '==': Value 1 equals value 2
- '===': Value 1 strictly equals value 2
- '!=': Value 1 does not equal value 2
- '!==': Value 1 strictly does not equal value 2
- '&gt;': Value 1 is greater than value 2
- '&lt;': Value 1 is less than value 2
- 'in': Value 1 can be found in an array defined as value 2
- 'not in': Value 1 cannot be found in an array defined as value 2
- 'and': Value 1 and value 2 must resolve to `true`
- '&amp;&amp;': Same as 'and'
- 'or': Value 1 or value 2 must resolve to `true`
- '||': Same as 'or'
- 'regex': Value 1 matches a pattern defined by value 2
- 'all':
    - All elements in an array defined by value 1 must be found in an array defined by value 2
    - **Or** If only one array is present, it must be reference nested rules that all resolve to `true`
- 'any':
    - Any element found in an array defined by value 1 must be found in an array defined by value 2
    - **Or** If only one array is present, it must reerence nested rules, for which at least one resolves to `true`
- 'none':
    - None of the elements in an array defined by value 1 may be present in an array defined by value 2
    - **Or** If only one array is present, it must reference nested rules that all resolve to `false` (or be empty)
- 'passes': Value 1 and the entire dataset being evaluated get passed to a closure defgined by value 2, the output of which must resolve to `true`. This allows for custom rules behavior to be added.

### Sample Usage

[](#sample-usage)

`ruleConfig.php`

```
return [
    'isKevin' => [
        'reference1' => 'name.first',
        'comparator' => '==',
        'value2' => 'Kevin'
    ],
    'inCarolinas' => [
        'reference1' => 'address.state',
        'comparator => 'in',
        'value2' => [
            'NC',
            'SC'
        ]
    ],
    'isMe' => [
        'comparator' => 'all',
        'value2' => [
            'isKevin',
            'inCarolinas
        ]
    ]
];
```

`data.json`

```
{
  "name": {
    "first": "Kevin"
  },
  "address": {
      "state": "NC"
  }
}
```

```
use Evaluator\Parsers\ConfigParser;

$rules = require_once 'ruleConfig.php';
$data = json_decode(file_get_contents("data.json"), true);
$data = array_dot($data);

$ result = (new ConfigParser($data, $rules))->evaluate('isMe'); // true
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2287d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/86619ba927c0055375588f0c21d6d0d89be6a74e4a2cb98558062c852ebe5c66?d=identicon)[kmuenkel](/maintainers/kmuenkel)

---

Top Contributors

[![kmuenkel](https://avatars.githubusercontent.com/u/17931045?v=4)](https://github.com/kmuenkel "kmuenkel (7 commits)")

---

Tags

searcharraystringdot notationrule-engine

### Embed Badge

![Health badge](/badges/kmuenkel-rule-evaluator/health.svg)

```
[![Health](https://phpackages.com/badges/kmuenkel-rule-evaluator/health.svg)](https://phpackages.com/packages/kmuenkel-rule-evaluator)
```

###  Alternatives

[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[phootwork/lang

Missing PHP language constructs

1224.8M8](/packages/phootwork-lang)[rpnzl/arrch

Array queries for PHP 5.3

37134.6k2](/packages/rpnzl-arrch)[michaldudek/foundation

A set of useful PHP classes.

13111.9k13](/packages/michaldudek-foundation)[dotty/dotty

Easy access to array data using dot notation

1293.7k1](/packages/dotty-dotty)[clausnz/php-helpers

A Collection of useful php helper functions.

388.7k](/packages/clausnz-php-helpers)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
