PHPackages                             keboola/filter - 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. keboola/filter

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

keboola/filter
==============

Simple comparison filter

2.0.0(5y ago)13.9k↓33.3%[1 PRs](https://github.com/keboola/php-filter/pulls)1MITPHPPHP &gt;=7.4

Since Jul 9Pushed 3y ago17 watchersCompare

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

READMEChangelog (1)Dependencies (5)Versions (12)Used By (1)

Filter
======

[](#filter)

Description
-----------

[](#description)

Compare values in objects against pre-set values in the filter. The filter is constructed from a string with a key (field name in the the object), operator and a value to be compared against. Then an object is passed to the filter and evaluated whether it passes the filter or not.

Usage
-----

[](#usage)

```
use Keboola\Filter\Filter;

// Compare the `shoeSize` property of John
$john = new \stdClass();
$john->shoeSize = 45;
$filter = FilterFactory::create("shoeSize>42");
$filter->compareObject($john); // true

// Multiple conditions can be used
$filter = FilterFactory::create("field1==0&field2!=0");
$object = (object) [
    'field1' => 0,
    'field2' => 1
];
$result = $filter->compareObject($object); // true
```

- The filter is whitespace sensitive, therefore `value == 100` will look into `value␣` for a `␣100` value, instead of `value` and `100` as likely desired.
- **Correct** use: `value==100`
- **Wrong** use: `value == 100`

Supported comparison operators
------------------------------

[](#supported-comparison-operators)

- `` -- greater than
- `==` -- equals
- `=` -- greater or equals
- `!=` -- not equals
- `~~` -- like
- `!~` -- not like

### Like operator

[](#like-operator)

Like (and not like) operator allows you to use partial matching. Use a percent `%` character in the target value to match any number of characters, e.g.:

```
use Keboola\Filter\Filter;

// Compare the `shoeSize` property of John
$john = new \stdClass();
$john->name = "Johnny";
$filter = FilterFactory::create("name~~Johnny");
$filter->compareObject($john); // true
```

Supported logical operators
---------------------------

[](#supported-logical-operators)

With logical operators you can combine multiple conditions together. You can combine both conditions with different values and conditions with different keys. Supported logical operators:

- `&` -- logical and
- `|` -- logical or

### Usage

[](#usage-1)

- Case 1: Object's `status` must be `enabled` and `age` must be over `18`

`status==enabled&age>18`

```
{
    'status': 'enabled',
    'age': 20
}

```

`compareObject` on this object will return `true`.

```
{
    'status': 'enabled',
    'age': 15
}

```

`compareObject` on this object will return `false`.

- Case 2: Object's `status` must be `new` or `udated`

`status==new|status==updated`

```
{
    'status': 'new'
}

```

`compareObject` on this object will return `true`.

```
{
    'status': 'updated'
}

```

`compareObject` on this object will return `true`.

```
{
    'status': 'closed'
}

```

`compareObject` on this object will return `false`.

### Combining logical operators

[](#combining-logical-operators)

Parentheses are not supported, however the standard operator precedence is applied (`&` precedes `|`). For example, the expression `a==b&c==d|e==f` is interpreted as `(a==b&c==d)|e==f` and the
expression `a==b&c==d|e==f&g==h` translates into `(a==b&c==d)|(e==f&g==h)`.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 72.7% 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 ~289 days

Recently: every ~419 days

Total

8

Last Release

1944d ago

Major Versions

0.1.4 → 1.0.02017-06-21

1.1.0 → 2.0.02021-01-20

PHP version history (4 changes)0.1.0PHP &gt;=5.4.0

0.1.1PHP &gt;=5.6.0

1.0.0PHP &gt;=7.0

2.0.0PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/101dbf2551a0709ddab522f97669f13a2c4cc2d0a1e8d009f3af6ba80accb1a9?d=identicon)[Keboola](/maintainers/Keboola)

---

Top Contributors

[![odinuv](https://avatars.githubusercontent.com/u/4319320?v=4)](https://github.com/odinuv "odinuv (16 commits)")[![michaljurecko](https://avatars.githubusercontent.com/u/19371734?v=4)](https://github.com/michaljurecko "michaljurecko (4 commits)")[![MiroCillik](https://avatars.githubusercontent.com/u/1488015?v=4)](https://github.com/MiroCillik "MiroCillik (2 commits)")

---

Tags

characterfilterphpexpressionsgeneric extractor

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/keboola-filter/health.svg)

```
[![Health](https://phpackages.com/badges/keboola-filter/health.svg)](https://phpackages.com/packages/keboola-filter)
```

###  Alternatives

[spatie/regex

A sane interface for php's built in preg\_\* functions

1.1k17.1M59](/packages/spatie-regex)[selvinortiz/flux

Fluent regular expressions in PHP.

3372.0k1](/packages/selvinortiz-flux)

PHPackages © 2026

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