PHPackages                             clutz88/enum-comparison - 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. clutz88/enum-comparison

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

clutz88/enum-comparison
=======================

A package for adding comparison functions to enum classes

v0.0.3(1y ago)00[3 PRs](https://github.com/Clutz88/enum-comparison/pulls)MITPHPPHP ^8.2CI passing

Since Nov 28Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Clutz88/enum-comparison)[ Packagist](https://packagist.org/packages/clutz88/enum-comparison)[ Docs](https://github.com/clutz88/enum-comparison)[ GitHub Sponsors](https://github.com/Clutz88)[ RSS](/packages/clutz88-enum-comparison/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (7)Used By (0)

A package for adding comparison functions to enum classes
=========================================================

[](#a-package-for-adding-comparison-functions-to-enum-classes)

[![Latest Version on Packagist](https://camo.githubusercontent.com/bcf7531b7e69a954854aa21e5fd2413317ccf9706f7fb13a8606806ce9e9e524/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636c75747a38382f656e756d2d636f6d70617269736f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/clutz88/enum-comparison)[![Tests](https://camo.githubusercontent.com/61befab4838ecd77ca6922488953a35cd2b3befec60e748eb14d64b5fad8f6a3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636c75747a38382f656e756d2d636f6d70617269736f6e2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/clutz88/enum-comparison/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/e08f0333fe4f64229a462445a4df3295889dedbd3503e8631fec535cf40580d8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636c75747a38382f656e756d2d636f6d70617269736f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/clutz88/enum-comparison)

Provide functions that can be used in Enums for easy comparisons, such as:

```
TestEnum::test->equals('test')
```

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

[](#installation)

You can install the package via composer:

```
composer require clutz88/enum-comparison
```

Usage
-----

[](#usage)

Add the trait to your enums

```
enum TestEnum: string
{
    use HasComparisons;

    case test = 'test';
}
```

Call the provided functions when you want to do a comparison of an Enum value

```
$value_to_test = 'test';
$enum_value_to_test = TestEnum::test;

TestEnum::test->is($enum_value_to_test); // true
TestEnum::test->is($value_to_test); // false
TestEnum::test->isNot($enum_value_to_test); // false
TestEnum::test->isNot($value_to_test); // true
TestEnum::test->equals($value_to_test); // true
TestEnum::test->equals('testing'); // false
TestEnum::test->notEquals('testing'); // true

$enum_value_to_test->equals($value_to_test); // true
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- [Chris Cutts](https://github.com/Clutz88)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance68

Regular maintenance activity

Popularity0

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 54.5% 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 ~0 days

Total

3

Last Release

535d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/94211707cb63e8d7e14dd17943b34e392bfa4e5be4c016b851703dfc46210870?d=identicon)[chriscutts](/maintainers/chriscutts)

---

Top Contributors

[![Clutz88](https://avatars.githubusercontent.com/u/156974794?v=4)](https://github.com/Clutz88 "Clutz88 (12 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")

---

Tags

Clutz88enum-comparison

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/clutz88-enum-comparison/health.svg)

```
[![Health](https://phpackages.com/badges/clutz88-enum-comparison/health.svg)](https://phpackages.com/packages/clutz88-enum-comparison)
```

PHPackages © 2026

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