PHPackages                             sinevia/php-library-business-rule - 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. sinevia/php-library-business-rule

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

sinevia/php-library-business-rule
=================================

PHP Library Business Rule

v1.1.0(4y ago)6662proprietaryPHPCI failing

Since Sep 19Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Sinevia/php-library-business-rule)[ Packagist](https://packagist.org/packages/sinevia/php-library-business-rule)[ Docs](http://github.com/sinevia/php-library-uid)[ RSS](/packages/sinevia-php-library-business-rule/feed)WikiDiscussions master Synced yesterday

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

PHP Library Business Rule
=========================

[](#php-library-business-rule)

[![No Dependencies](https://camo.githubusercontent.com/e5650883bec05bec967678c8203c32b160b75c93b5b745c80bd9e6f25eb4a3db/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6e6f2d646570656e64656e636965732d737563636573732e737667)](https://camo.githubusercontent.com/e5650883bec05bec967678c8203c32b160b75c93b5b745c80bd9e6f25eb4a3db/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6e6f2d646570656e64656e636965732d737563636573732e737667)[![Tests](https://github.com/Sinevia/php-library-business-rule/workflows/php/badge.svg)](https://github.com/Sinevia/php-library-business-rule/workflows/php/badge.svg)[![Gitpod Ready-to-Code](https://camo.githubusercontent.com/ec0084907bd5b3576af415a1e46cae636fbfa04da6bf9db6296eae3057a189f0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f476974706f642d52656164792d2d746f2d2d436f64652d626c75653f6c6f676f3d676974706f64)](https://gitpod.io/#https://github.com/Sinevia/php-library-business-rule)

A business rule defines or constrains some aspect of business. Given a specified context (data) a business rule always resolves to either true or false.

Formal specification: // Given {context} When {condition(s)} Then {pass} Or {fail}

Usage
-----

[](#usage)

1. Direct usage

```
$rule = (new BusinessRule())->context([])->condition(function($context){ return true; });

if ($rule->fails()) {
    // Execute fail logic
}

if ($rule->passes()) {
    // Execute pass logic
}
```

2. Extend into a separate class. Allows to be re-used (avoid duplication of business logic)

```
// 1. Specify the business rule class
class AllowAccessRule extends BusinessRule {
    function __construct() {
        $this->condition(function($context){
            return ($context['user']->isEmailConfirmed() AND $context['user']->isActive());
        });
    }
}

// Use the shortcut init function with the context to initialize the rule
if (AllowAccessRule::init(['user'=>$user)->fails()) {
    die('You are not allowed access to this part of the website');
}
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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

Every ~922 days

Total

2

Last Release

1505d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d935723d26f92caa8fb66c4a44cf1995c488734b54e36f5b616ac290a109ab59?d=identicon)[sinevia](/maintainers/sinevia)

---

Top Contributors

[![Sinevia](https://avatars.githubusercontent.com/u/3450815?v=4)](https://github.com/Sinevia "Sinevia (12 commits)")[![valentin-iordanov](https://avatars.githubusercontent.com/u/72465027?v=4)](https://github.com/valentin-iordanov "valentin-iordanov (4 commits)")

---

Tags

phpbusinesslibraryrulesinevia

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sinevia-php-library-business-rule/health.svg)

```
[![Health](https://phpackages.com/badges/sinevia-php-library-business-rule/health.svg)](https://phpackages.com/packages/sinevia-php-library-business-rule)
```

PHPackages © 2026

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