PHPackages                             tenthfeet/enums - 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. tenthfeet/enums

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

tenthfeet/enums
===============

Helpers for PHP enums

v1.1.1(3mo ago)118↓100%MITPHPPHP ^8.1

Since Jan 3Pushed 3mo agoCompare

[ Source](https://github.com/tenthfeet/enums)[ Packagist](https://packagist.org/packages/tenthfeet/enums)[ RSS](/packages/tenthfeet-enums/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Enums
=====

[](#enums)

A lightweight PHP trait that adds **powerful, type-safe helper methods** to PHP 8.1+ enums. Designed for pure PHP projects, with seamless compatibility for frameworks such as Laravel, Symfony, or Slim.

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

[](#requirements)

- PHP 8.1 or higher
- Native PHP enums (PureEnum, BackedEnum)

No external dependencies.

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

[](#installation)

Via Composer (recommended)

```
  composer require tenthfeet/enums
```

Usage/Examples
--------------

[](#usageexamples)

1.Add the trait to your enum

```
use Tenthfeet\Enums\Traits\InteractWithCases;

enum Status
{
    use InteractWithCases;

    case Active;
    case Inactive;
}
```

For backed enums:

```
use Tenthfeet\Enums\Traits\InteractWithCases;

enum PaymentStatus: int
{
    use InteractWithCases;

    case Pending = 1;
    case Paid = 2;
}
```

**Instance Methods**

`is()` / `isNot()`

Strict identity comparison between enum cases.

```
Status::Active->is(Status::Active);      // true
Status::Active->is(Status::Inactive);    // false

Status::Active->isNot(Status::Inactive); // true
```

`in()` / `notIn()`

Check if an enum exists within an iterable collection.

```
Status::Active->in([Status::Inactive, Status::Active]); // true
Status::Active->notIn([Status::Inactive]);              // true
```

- Ignores non-enum values safely
- Uses strict enum identity comparison

`__invoke()`

Calling an enum case as a function returns:

- the value for backed enums
- the name for pure enums

```
Status::Active();         // "Active"
PaymentStatus::Paid();   // 2
```

**Static Methods**

`names()`

Returns all enum case names.

```
Status::names(); // ["Active", "Inactive"]
```

`values()`

Returns:

- enum values for backed enums
- enum names for pure enums

```
PaymentStatus::values();  // [1, 2]

Status::values();         // ["Active", "Inactive"]
```

`options()`

Generates a standardized array of options, ideal for:

- HTML select inputs
- API responses
- Frontend frameworks

```
Status::options();

// Output
[
    ['id' => 'Active', 'text' => 'Active'],
    ['id' => 'Inactive', 'text' => 'Inactive'],
]
```

Using a custom label method

```
enum PaymentStatus: int
{
    use InteractWithCases;

    case Pending = 1;
    case Paid = 2;

    public function label(): string
    {
        return match ($this) {
            self::Pending => 'Not Received',
            self::Paid => 'Received',
        };
    }
}

PaymentStatus::options('label');

// Output
[
    ['id' => 1, 'text' => 'Not Received'],
    ['id' => 2, 'text' => 'Received'],
]
```

Custom keys

```
PaymentStatus::options(property: 'label', valueKey: 'value', nameKey: 'label');

// Output
[
    ['value' => 1, 'label' => 'Not Received'],
    ['value' => 2, 'label' => 'Received'],
]
```

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance85

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

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

Every ~8 days

Total

3

Last Release

110d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/af032b274982990a0429c5d5f74ba2dd3a18b0f6e7c95b6c4666237a5599e7e4?d=identicon)[Tenthfeet](/maintainers/Tenthfeet)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tenthfeet-enums/health.svg)

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

###  Alternatives

[froiden/laravel-installer

Laravel web installer

10883.9k](/packages/froiden-laravel-installer)

PHPackages © 2026

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