PHPackages                             xepozz/matcher - 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. xepozz/matcher

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

xepozz/matcher
==============

00PHP

Since Nov 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/xepozz/matcher)[ Packagist](https://packagist.org/packages/xepozz/matcher)[ RSS](/packages/xepozz-matcher/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Matcher
=======

[](#matcher)

A way to match values against a pattern.

[![Latest Stable Version](https://camo.githubusercontent.com/b09d4e523fea6f947b10cdec3df0f5a516d4607efb288dc9d56c7245ad0a419b/68747470733a2f2f706f7365722e707567782e6f72672f7865706f7a7a2f6d6174636865722f762f737461626c652e737667)](https://packagist.org/packages/xepozz/matcher)[![Total Downloads](https://camo.githubusercontent.com/e044523cd58fc4ded957f097574c46eb31d162dd8a0c77bcf462c155021886d7/68747470733a2f2f706f7365722e707567782e6f72672f7865706f7a7a2f6d6174636865722f646f776e6c6f6164732e737667)](https://packagist.org/packages/xepozz/matcher)[![phpunit](https://github.com/xepozz/matcher/workflows/PHPUnit/badge.svg)](https://github.com/xepozz/matcher/actions)[![codecov](https://camo.githubusercontent.com/6ddef499ba8bce8b201911b7ac15147011ac064b59620da26e25e8c34551b27a/68747470733a2f2f636f6465636f762e696f2f67682f7865706f7a7a2f6d6174636865722f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d55524558414f5548544a)](https://codecov.io/gh/xepozz/matcher)

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

[](#installation)

```
composer require xepozz/matcher
```

Usage
-----

[](#usage)

### Basic concept

[](#basic-concept)

A matcher is an object that is filled with a value and callbacks that will be called if the value matches the pattern.

### Basic example

[](#basic-example)

```
use Xepozz\Matcher\StringMatcher;

/**
 * Each with* method returns a new instance of the matcher with the added condition.
 * So that means that the original matcher is not changed and you must use the returned instance.
 */
$matcher = (new StringMatcher('foo')) // or StringMatcher::of('foo')
    ->withLengthGreaterThan(2)
    ->withLengthLessThan(10)
    ->withContains('fo')
    ->withEndsWith('oo')
    ->withStartsWith('fo')
    ->with(function (string $value) {
        return $value === 'foo'; // callback for any custom checks
    });

$matcher->matches(); // true
```

### Combining matchers

[](#combining-matchers)

```
use Xepozz\Matcher\LogicMatcher;use Xepozz\Matcher\StringMatcher;

$logicMatcher = new LogicMatcher();
$stringMatcher = new StringMatcher('bar');

$stringMatcher->matches(); // true
$logicMatcher->not($stringMatcher)
    ->matches(); // false

$stringMatcher->matches(); // true
$logicMatcher->or($logicMatcher->not($stringMatcher), $stringMatcher)
    ->matches(); // true

$logicMatcher->or($logicMatcher->not($stringMatcher), $logicMatcher->not($stringMatcher))
    ->matches(); // false

$logicMatcher->and($stringMatcher, $logicMatcher->not($stringMatcher))
    ->matches(); // false
```

Existing Matchers
-----------------

[](#existing-matchers)

- [Xepozz\\Matcher\\LogicMatcher](src/LogicMatcher.php)
- [Xepozz\\Matcher\\StringMatcher](src/StringMatcher.php)
- [Xepozz\\Matcher\\IntegerMatcher](src/IntegerMatcher.php)
- [Xepozz\\Matcher\\ObjectMatcher](src/ObjectMatcher.php)

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity17

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6815714?v=4)[Dmitrii Derepko](/maintainers/xepozz)[@xepozz](https://github.com/xepozz)

---

Top Contributors

[![xepozz](https://avatars.githubusercontent.com/u/6815714?v=4)](https://github.com/xepozz "xepozz (16 commits)")

### Embed Badge

![Health badge](/badges/xepozz-matcher/health.svg)

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

###  Alternatives

[ikr/money-math

gmp-based arbitrary precision operations on currency amounts "XXX.YY"; because floats are BAD for representing money

3216.1k1](/packages/ikr-money-math)

PHPackages © 2026

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