PHPackages                             complex-heart/criteria - 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. complex-heart/criteria

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

complex-heart/criteria
======================

Small implementation of a filter criteria pattern in PHP for Complex Heart SDK. Compose several filters using fluent interface.

v4.2.0(8mo ago)51.7k1Apache-2.0PHPPHP ^8.2CI passing

Since Jun 28Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/ComplexHeart/php-criteria)[ Packagist](https://packagist.org/packages/complex-heart/criteria)[ RSS](/packages/complex-heart-criteria/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (8)Versions (12)Used By (1)

Criteria
========

[](#criteria)

[![Test](https://github.com/ComplexHeart/php-criteria/actions/workflows/test.yml/badge.svg)](https://github.com/ComplexHeart/php-criteria/actions/workflows/test.yml)[![Quality Gate Status](https://camo.githubusercontent.com/44fa99e82ee579a98d18a632da5bc094dd12823243f8c361042d9edaac5403e6/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d436f6d706c657848656172745f7068702d6372697465726961266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/summary/new_code?id=ComplexHeart_php-criteria)[![Coverage](https://camo.githubusercontent.com/438bbdbfb0fc118f311f1f094206d0a96f3114161bd953615e1b80bf80f12e4f/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d436f6d706c657848656172745f7068702d6372697465726961266d65747269633d636f766572616765)](https://sonarcloud.io/summary/new_code?id=ComplexHeart_php-criteria)

Small implementation of a criteria pattern in PHP for Complex Heart SDK. Compose several filters using fluent interface.

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

[](#installation)

Just install the package from Packagist using composer:

```
composer require complex-heart/criteria
```

Usage
-----

[](#usage)

Import the class and use the fluent interface:

```
namespace ComplexHeart\Domain\Criteria;

// Match the users with status active and more than 7k followers and from Spain and France
$g1 = FilterGroup::create()
    ->addFilterEqual('status', 1)
    ->addFilterGreaterThan('followers', 7000)
    ->addFilterIn('country', ['es', 'fr']);

$criteria = Criteria::default()
    ->withFilterGroup($g1)
    ->withOrderBy('surname')
    ->withOrderType('asc')
    ->withPageLimit(25)
    ->withPageOffset(50);

$users = $repository->match($criteria);

// alternative, same as above
$criteria = Criteria::default()
    ->withFilterGroup(FilterGroup::create()
        ->addFilterEqual('status', 1)
        ->addFilterGreaterThan('followers', 7000)
        ->addFilterIn('country', ['es', 'fr']))
    ->withOrderBy('surname')
    ->withOrderType('asc')
    ->withPageLimit(25)
    ->withPageOffset(50);

// In SQL, we may have something like:
// WHERE status = 1 AND followers >= 700 AND country in ('es', 'fr')

$users = $repository->match($criteria);
```

A `FilterGroup` is a set of filters or conditions that must match all together (`AND`). To match one group or another (`OR`), just add more `FilterGroup`.

```
// Match articles with given term in title, or in tagline, or in content.
$criteria = Criteria::default()
    ->withFilterGroup(FilterGroup::create()->addFilterContains('title', $term))
    ->withFilterGroup(FilterGroup::create()->addFilterContains('tagline', $term))
    ->withFilterGroup(FilterGroup::create()->addFilterContains('content', $term))
    ->withOrderBy('created_at')
    ->withOrderType(Order::TYPE_ASC)
    ->withPageNumber(3);
```

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance70

Regular maintenance activity

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity71

Established project with proven stability

 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

Every ~157 days

Recently: every ~140 days

Total

11

Last Release

260d ago

Major Versions

v1.0.2 → v2.0.02022-11-12

v2.0.0 → v3.0.02024-01-30

v3.0.1 → v4.0.02024-04-02

PHP version history (5 changes)v1.0.0PHP ^7.4|^8.0

v1.0.1PHP ^7.4|^8.0|^8.1

v2.0.0PHP ^8.0.2

v3.0.0PHP ^8.1

v4.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/7958790dcf5cd51ebbadc52fc7bada326fb3edd4481decf1006e6cfed8e46c43?d=identicon)[usantisteban](/maintainers/usantisteban)

---

Top Contributors

[![othercodes](https://avatars.githubusercontent.com/u/4815856?v=4)](https://github.com/othercodes "othercodes (39 commits)")

---

Tags

criteriafilterphpspecification-pattern

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/complex-heart-criteria/health.svg)

```
[![Health](https://phpackages.com/badges/complex-heart-criteria/health.svg)](https://phpackages.com/packages/complex-heart-criteria)
```

###  Alternatives

[humaidem/filament-map-picker

5921.6k](/packages/humaidem-filament-map-picker)

PHPackages © 2026

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