PHPackages                             scheb/comparator - 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. scheb/comparator

AbandonedArchivedLibrary

scheb/comparator
================

Compares to values for equality

v1.0.0(7y ago)21441MITPHPPHP ^7.1.3

Since Sep 2Pushed 7y ago1 watchersCompare

[ Source](https://github.com/scheb/comparator)[ Packagist](https://packagist.org/packages/scheb/comparator)[ Docs](https://github.com/scheb/comparator)[ RSS](/packages/scheb-comparator/feed)WikiDiscussions master Synced 3d ago

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

scheb/comparator
================

[](#schebcomparator)

[![Build Status](https://camo.githubusercontent.com/6289d7a2583e1b9c522d634917af57eb8ffbbf360d686abc85ecf00583e4ac6f/68747470733a2f2f7472617669732d63692e6f72672f73636865622f636f6d70617261746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/scheb/comparator)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/4d62eacdce758f62e2bf964f6d104a2b942ee533141b3ce9957ba3471794e828/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73636865622f636f6d70617261746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/scheb/comparator/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/0bc8c43d3a55e1320153162d7f6e266dd9beff893a364c311262389dbf24615a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73636865622f636f6d70617261746f722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/scheb/comparator/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/a2aefa07d43ae9abafde2d91aaafcf04621cc8592b902fc59ef007eaf4953e9e/68747470733a2f2f706f7365722e707567782e6f72672f73636865622f636f6d70617261746f722f762f737461626c652e737667)](https://packagist.org/packages/scheb/comparator)[![License](https://camo.githubusercontent.com/269f79b5374cc716d40951147197c70544fee4006584e508e0aa8979b536d1d5/68747470733a2f2f706f7365722e707567782e6f72672f73636865622f636f6d70617261746f722f6c6963656e73652e737667)](https://packagist.org/packages/scheb/comparator)

This library compares two values for equality.

If you need to add your own rules for comparing specific values, you can extend the library with your own comparison strategies.

Features
--------

[](#features)

- Simple equality comparison (`==` or `===`)
- Strategy interface for your own comparison rules

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

[](#installation)

```
composer require scheb/comparator
```

How to use
----------

[](#how-to-use)

```
$comparator = new \Scheb\Comparator\Comparator(true); // Type-sensive equal (===)
$comparator->isEqual(0, "0"); // Returns false
$comparator->isEqual(0, ""); // Returns false
$comparator->isEqual(0, 0); // Returns true
$comparator->isEqual(0, "foo"); // Returns false

$comparator = new \Scheb\Comparator\Comparator(false); // Type-insensive equal (==)
$comparator->isEqual(0, "0"); // Returns true
$comparator->isEqual(0, ""); // Returns true
$comparator->isEqual(0, 0); // Returns true
$comparator->isEqual(0, "foo"); // Returns false
```

How to extend
-------------

[](#how-to-extend)

To add your own comparison strategy, implement `Scheb\Comparator\ValueComparisonStrategyInterface`.

Then, add an instance of that class via the constructor argument `$customComparisonStrategies` of `Scheb\Comparator\Comparator`.

Custom comparison strategies take preference over default ones.

Contribute
----------

[](#contribute)

You're welcome to [contribute](https://github.com/scheb/comparator/graphs/contributors) to this library by creating a pull requests or feature request in the issues section. For pull requests, please follow these guidelines:

- Symfony code style
- PHP7.1 type hints for everything (including: return types, `void`, nullable types)
- Please add/update test cases
- Test methods should be named `[method]_[scenario]_[expected result]`

To run the test suite install the dependencies with `composer install` and then execute `bin/phpunit`.

License
-------

[](#license)

This bundle is available under the [MIT license](LICENSE).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

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

2811d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/496658d46619a414a62b1e933fb7fc2e57eff4f0a4109f4cffc32093f57d65da?d=identicon)[scheb](/maintainers/scheb)

---

Top Contributors

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

---

Tags

comparatorcompare-valuesequalitymatchingequalitycomparecomparatormatching

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/scheb-comparator/health.svg)

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

###  Alternatives

[sebastian/comparator

Provides the functionality to compare PHP values for equality

7.0k879.8M145](/packages/sebastian-comparator)[icecave/parity

A customizable deep comparison library.

516.8M10](/packages/icecave-parity)[mlocati/ip-lib

Handle IPv4, IPv6 addresses and ranges

3126.4M44](/packages/mlocati-ip-lib)[longman/ip-tools

PHP IP Tools for manipulation with IPv4 and IPv6

147245.6k6](/packages/longman-ip-tools)[phootwork/lang

Missing PHP language constructs

1224.8M8](/packages/phootwork-lang)[dragon-code/benchmark

Simple comparison of code execution speed between different options

11934.7k5](/packages/dragon-code-benchmark)

PHPackages © 2026

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