PHPackages                             ali-eltaweel/predkit - 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. ali-eltaweel/predkit

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

ali-eltaweel/predkit
====================

A collection of composable predicate classes for PHP, allowing flexible combination of conditions using binary operations such as AND, OR, and more.

1.0.0(10mo ago)081PHPPHP ^8.1

Since Jun 14Pushed 10mo agoCompare

[ Source](https://github.com/ali-eltaweel/predkit)[ Packagist](https://packagist.org/packages/ali-eltaweel/predkit)[ RSS](/packages/ali-eltaweel-predkit/feed)WikiDiscussions master Synced 1mo ago

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

Predkit
=======

[](#predkit)

**Composable predicate classes for PHP, allowing flexible combination of conditions using binary operations.**

- [Predkit](#predkit)
    - [Installation](#installation)
    - [Usage](#usage)
        - [Creating predicates](#creating-predicates)
            - [By extending the Predicate class](#by-extending-the-predicate-class)
            - [By speciying a callable](#by-speciying-a-callable)
        - [Using predicates](#using-predicates)
        - [Combining predicates](#combining-predicates)

---

Installation
------------

[](#installation)

Install *predkit* via Composer:

```
composer require ali-eltaweel/predkit
```

Usage
-----

[](#usage)

### Creating predicates

[](#creating-predicates)

#### By extending the Predicate class

[](#by-extending-the-predicate-class)

```
use Predkit\Predicate;

class IsEven extends Predicate {

    public function test(mixed $number): bool {

        return $number % 2 === 0;
    }
}

$predicate = new IsEven();
```

#### By speciying a callable

[](#by-speciying-a-callable)

```
use Predkit\Predicate;

$predicate = Predicate::fromCallable(function (mixed $number): bool {

    return $number % 2 === 0;
});
```

---

### Using predicates

[](#using-predicates)

```
$predicate->test(4); // true
$predicate->test(5); // false

$evenNumbers = array_filter([1, 2, 3, 4, 5], $predicate); // [2, 4]
```

---

### Combining predicates

[](#combining-predicates)

Predicates can be combined using binary operations. The result is a new predicate that represents the combination of the original predicates.

```
use Predkit\Predicate;

$evenPredicate = Predicate::fromCallable(function (mixed $number): bool {

    return $number % 2 === 0;
});

$greaterThanFivePredicate = Predicate::fromCallable(function (mixed $number): bool {

    return $number > 5;
});

// and
$evenAndGreaterThanFivePredicate = $evenPredicate->and($greaterThanFivePredicate);
array_filter(range(0, 10), $evenAndGreaterThanFivePredicate); // [6, 8, 10]

// or
$evenOrGreaterThanFivePredicate  = $evenPredicate->or($greaterThanFivePredicate);
array_filter(range(0, 10), $evenOrGreaterThanFivePredicate); // [0, 2, 4, 6, 7, 8, 9, 10]

// not
$oddPredicate = $evenPredicate->not();
array_filter(range(0, 10), $oddPredicate); // [1, 3, 5, 7, 9]

// nand
$evenNandGreaterThanFivePredicate = $evenPredicate->nand($greaterThanFivePredicate);
array_filter(range(0, 10), $evenNandGreaterThanFivePredicate); // [0, 1, 2, 3, 4, 5, 7, 9]

// nor
$evenNorGreaterThanFivePredicate = $evenPredicate->nor($greaterThanFivePredicate);
array_filter(range(0, 10), $evenNorGreaterThanFivePredicate); // [1, 3, 5]

// xor
$evenXorGreaterThanFivePredicate = $evenPredicate->xor($greaterThanFivePredicate);
array_filter(range(0, 10), $evenXorGreaterThanFivePredicate); // [ 0, 2, 4, 7, 9 ]

// xnor
$evenXnorGreaterThanFivePredicate = $evenPredicate->xnor($greaterThanFivePredicate);
array_filter(range(0, 10), $evenXnorGreaterThanFivePredicate); // [ 1, 3, 5, 6, 8, 10 ]
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance55

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity45

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

328d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7564e10ba11b25d8700726a92f669e38be2ff9191e8f6ccdfafc36678ffab2b8?d=identicon)[ali-eltaweel](/maintainers/ali-eltaweel)

---

Top Contributors

[![ali-eltaweel](https://avatars.githubusercontent.com/u/45892756?v=4)](https://github.com/ali-eltaweel "ali-eltaweel (2 commits)")

### Embed Badge

![Health badge](/badges/ali-eltaweel-predkit/health.svg)

```
[![Health](https://phpackages.com/badges/ali-eltaweel-predkit/health.svg)](https://phpackages.com/packages/ali-eltaweel-predkit)
```

###  Alternatives

[kaufmanndigital/gdpr-cookieconsent

A ready-to-run package, that integrates an advanced cookie consent banner into your Neos CMS site.

2540.7k](/packages/kaufmanndigital-gdpr-cookieconsent)[selective/transformer

A strictly typed array transformer with dot-access, fluent interface and filters.

3817.8k1](/packages/selective-transformer)[derhansen/sf_banners

Banner-Management Extension based on Extbase and Fluid. Loads banners asynchronously using JavaScript.

1144.5k](/packages/derhansen-sf-banners)[martin/wn-forms-plugin

Create easy (and almost magic) AJAX forms

212.3k](/packages/martin-wn-forms-plugin)

PHPackages © 2026

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