PHPackages                             rocksheep/enum-helpers - 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. rocksheep/enum-helpers

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

rocksheep/enum-helpers
======================

A collection of helper functions for working with enums in PHP

v1.0.1(1y ago)010.6k↑15%MITPHPPHP ^8.1

Since Jul 5Pushed 1y ago1 watchersCompare

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

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

Enum Helpers
============

[](#enum-helpers)

[![PHP from Packagist](https://camo.githubusercontent.com/4c699d4aeaec4e69ac6c714d35cde2f6de754fe8ec5144266ea8e8b9a389ff78/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f726f636b73686565702f656e756d2d68656c706572732e737667)](https://packagist.org/packages/rocksheep/enum-helpers)[![Latest Version on Packagist](https://camo.githubusercontent.com/dd974b1f75b561cae0db2c733a7bf98dc4c95fd5988d47cf553926be869a0099/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f636b73686565702f656e756d2d68656c706572732e737667)](https://packagist.org/packages/rocksheep/enum-helpers)[![Software License](https://camo.githubusercontent.com/fc468de91995215134fbf663e1a39c4b093e9c9346f39ca9c05ed5b785ef890e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f726f636b73686565702f656e756d2d68656c706572732e737667)](LICENSE)[![Build Status](https://camo.githubusercontent.com/35903a658c76f66ecfd8595d7ea123ed78bab42d78afd75692d59ca61854bfac/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f526f636b73686565702f656e756d2d68656c706572732f7068702e796d6c3f6272616e63683d6d61696e)](https://github.com/rocksheep/enum-helpers/actions/workflows/php.yml)

This package provides a set of utilities to work with PHP enums, making it easier to convert enums to arrays and handle hidden enum cases. It leverages PHP 8.1's enum feature, adding functionality to enhance its usability within your projects.

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

[](#installation)

You can install the package via composer:

```
composer require rocksheep/enum-helpers
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

To use the `EnumToArray` trait in your enum, simply use it within your enum definition:

```
use Rocksheep\EnumHelpers\EnumToArray;

enum YourEnum: string
{
    use EnumToArray;

    case Example = 'example';
}
```

This will allow you to convert your enum cases to an array easily.

### Hiding Enum Cases

[](#hiding-enum-cases)

To hide specific enum cases from being listed, use the Hidden attribute:

```
use Rocksheep\EnumHelpers\Attributes\Hidden;
use Rocksheep\EnumHelpers\EnumToArray;

enum YourEnum: string
{
    use EnumToArray;

    case Visible = 'visible';

    #[Hidden]
    case Hidden = 'hidden';
}
```

### Converting Enum to Array

[](#converting-enum-to-array)

To convert an enum to an array, simply call the `toArray` method:

```
$array = YourEnum::toArray(); // ['visible' => 'Visible']
```

Testing
-------

[](#testing)

To run the tests, execute:

```
./vendor/bin/pest
```

Or you can use:

```
composer test
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a pull request.

License
-------

[](#license)

The package is open-sourced software licensed under the MIT license.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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 ~0 days

Total

2

Last Release

682d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

phpenumhelpers

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rocksheep-enum-helpers/health.svg)

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

###  Alternatives

[transprime-research/piper

PHP Pipe method execution with values from chained method executions

174.6k2](/packages/transprime-research-piper)

PHPackages © 2026

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