PHPackages                             componenta/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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. componenta/filter

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

componenta/filter
=================

Composable filters for Componenta class discovery and reflection workflows

v1.0.0(1mo ago)091MITPHPPHP ^8.4

Since Jun 16Pushed 1mo agoCompare

[ Source](https://github.com/componenta/filter)[ Packagist](https://packagist.org/packages/componenta/filter)[ RSS](/packages/componenta-filter/feed)WikiDiscussions main Synced 1w ago

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

Componenta Filter
=================

[](#componenta-filter)

Composable filter objects for iterable data and reflection/class discovery.

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

[](#installation)

```
composer require componenta/filter
```

Requirements
------------

[](#requirements)

- PHP 8.4+
- `componenta/arrayable`

Related Packages
----------------

[](#related-packages)

PackageWhy it matters here`componenta/arrayable`Filters can expose their result through `toArray()`.`componenta/class-finder`Uses filters to select discovered classes, attributes, and reflection targets.`componenta/iterator`Can combine filtering with replayable iteration.What It Provides
----------------

[](#what-it-provides)

- `FilterInterface`: iterable filter contract with `accept()` and `toArray()`.
- `AbstractFilter`: base implementation for filtering an iterable source.
- `FilterableInterface` and `Filterable`: immutable filter-chain support.
- Concrete filters for scalars, arrays, strings, class names, reflection objects, files, ranges, callbacks, and composition.

Basic Usage
-----------

[](#basic-usage)

```
use Componenta\Filter\StringFilter;

$filter = new StringFilter(['one', 2, 'three']);

$filter->toArray(); // ['one', 'three']
```

Keys are not preserved by default:

```
$filter->toArray(preserveKeys: true);
```

Custom Criteria
---------------

[](#custom-criteria)

```
use Componenta\Filter\CallbackFilter;

$filter = new CallbackFilter(
    static fn(mixed $value, string|int|null $key): bool => is_int($value) && $value > 10,
    [5, 15, 20],
);

$filter->toArray(); // [15, 20]
```

Filter Chains
-------------

[](#filter-chains)

Objects using `Filterable` should return new instances when filters are added or removed.

```
$next = $filterable->withFilter($filter);
$sameWithout = $next->withoutFilter($filter);
```

`accept()` uses AND semantics: every registered filter must accept the value.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance91

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

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

43d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20490712?v=4)[Andrey Shelamkoff](/maintainers/Shelamkoff)[@Shelamkoff](https://github.com/Shelamkoff)

---

Top Contributors

[![Shelamkoff](https://avatars.githubusercontent.com/u/20490712?v=4)](https://github.com/Shelamkoff "Shelamkoff (1 commits)")

### Embed Badge

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

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

###  Alternatives

[hybridlogic/validation

A simple, extensible validation library for PHP with support for filtering and validating any input array along with generating client side validation code.

641.1k](/packages/hybridlogic-validation)

PHPackages © 2026

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