PHPackages                             coral-media/binary-rules-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. [Testing &amp; Quality](/categories/testing)
4. /
5. coral-media/binary-rules-evaluator

ActiveLibrary[Testing &amp; Quality](/categories/testing)

coral-media/binary-rules-evaluator
==================================

Choose an option based on binary rules for a set of conditions

0.1(3y ago)09MITPHPPHP ^7.4|^8.1

Since Feb 28Pushed 3y ago1 watchersCompare

[ Source](https://github.com/coral-media/binary-rules-evaluator)[ Packagist](https://packagist.org/packages/coral-media/binary-rules-evaluator)[ RSS](/packages/coral-media-binary-rules-evaluator/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Binary Rules Evaluator
======================

[](#binary-rules-evaluator)

Purpose
-------

[](#purpose)

Evaluate set of conditions avoiding redundant `if/else` statements.

How it works
------------

[](#how-it-works)

Having the following table:

Condition1Condition2Condition2**Result1**truefalsefalse**Result2**falsetruetrue**Result3**nulltruefalse**Result3**truenullfalse---

We translate that table into an array

```
$rulesTable = [
    'Result1' => [
        [
            'Condition1' => true,
            'Condition2' => false,
            'Condition3' => false
        ],
    ],
    'Result2' => [
        [
            'Condition1' => false,
            'Condition2' => true,
            'Condition3' => true
        ],
    ],
    'Result3' => [
        [
            'Condition1' => null,
            'Condition2' => true,
            'Condition3' => false
        ],
        [
            'Condition1' => true,
            'Condition2' => null,
            'Condition3' => false
        ],
    ],
];
```

Having as example the following inputs:

```
$input1 = [true, null, false] //matches Result3
$input2 = [null, null, false] //matches none
```

The validator will return the condition label or false if none matches. The `null` was added to represent unknown values and will not be evaluated.

```
$binaryRulesEvaluator = (new BinaryRulesEvaluator())
    ->setRulesTable($rulesTable);

$binaryRulesEvaluator->evaluate($input1); // 'Result3'
$binaryRulesEvaluator->evaluate($input2); // false
```

If more than one result share rules set, the method `validate`will return the first matching result.

This utility class helps to keep code consistent, clean and maintainable. Trust me, code with a lot of `if/elseif/else` statements can be really messy and hard to understand. Keep in mind almost always you would be able to turn any set of evaluations into a `true/false` table.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

1220d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5040695?v=4)[Rafael Ernesto Espinosa Santiesteban](/maintainers/rernesto)[@rernesto](https://github.com/rernesto)

---

Top Contributors

[![rernesto](https://avatars.githubusercontent.com/u/5040695?v=4)](https://github.com/rernesto "rernesto (3 commits)")

---

Tags

code-quality

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/coral-media-binary-rules-evaluator/health.svg)

```
[![Health](https://phpackages.com/badges/coral-media-binary-rules-evaluator/health.svg)](https://phpackages.com/packages/coral-media-binary-rules-evaluator)
```

###  Alternatives

[dms/phpunit-arraysubset-asserts

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

14429.2M360](/packages/dms-phpunit-arraysubset-asserts)

PHPackages © 2026

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