PHPackages                             anik/php-enum-enhancements - 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. anik/php-enum-enhancements

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

anik/php-enum-enhancements
==========================

Trait for PHP Enum type

v1.0(3y ago)01.2kMITPHPPHP ^8.1

Since May 23Pushed 3y ago1 watchersCompare

[ Source](https://github.com/ssi-anik/php-enum-enhancements)[ Packagist](https://packagist.org/packages/anik/php-enum-enhancements)[ RSS](/packages/anik-php-enum-enhancements/feed)WikiDiscussions main Synced today

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

anik/php-enum-enhancements [![codecov](https://camo.githubusercontent.com/217c3a6b8a4b1d5a3df35ce533d5a6c22bc0787ddae918f1c328b417b1b7dd0a/68747470733a2f2f636f6465636f762e696f2f67682f7373692d616e696b2f7068702d656e756d2d656e68616e63656d656e74732f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d39453934363543505041)](https://codecov.io/gh/ssi-anik/php-enum-enhancements)[![PHP Version Require](https://camo.githubusercontent.com/8a89bcfc3edd1d85924503139b5b9053c8e00ba98c27b405e0444acc06f2681a/687474703a2f2f706f7365722e707567782e6f72672f616e696b2f7068702d656e756d2d656e68616e63656d656e74732f726571756972652f706870)](//packagist.org/packages/anik/php-enum-enhancements)[![Latest Stable Version](https://camo.githubusercontent.com/5273988fd65a6fb4c2c7ea07788dcac71b217101e800f98aad8bdadd50dcacc9/68747470733a2f2f706f7365722e707567782e6f72672f616e696b2f7068702d656e756d2d656e68616e63656d656e74732f76)](//packagist.org/packages/anik/php-enum-enhancements)
===========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#anikphp-enum-enhancements)

**anik/php-enum-enhancements** provides a few methods to retrieve keys, values or kv pair on PHP Enums.

Documentation
=============

[](#documentation)

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

[](#installation)

To install the package, run

> composer require anik/php-enum-enhancements

Usage
-----

[](#usage)

Use the `Anik\PhpEnumEnhancements\Enhancement` trait in any of your Enum, and you'll have access to the following method.

```
# [\UnitEnum | \BackedEnum ]::case->getName(/* null or callable */)
# \BackedEnum::case->getValue(/* null or callable */)
# [\UnitEnum | \BackedEnum ]::names(/* null or callable */)
# \BackedEnum::values(/* null or callable */)
# \BackedEnum::kvPair(
        /* nameCallback: null or callable, */
        /* valueCallback: null or callable, */
        /* valueAsKey: bool */
#   )
```

Examples
--------

[](#examples)

For the enum below,

```
enum PostStatus: string {
    use \Anik\PhpEnumEnhancements\Enhancement;

    case DRAFT = 'draft';
    case UNDER_REVIEW = 'under_review';
    case PUBLISHED = 'published';
}
```

- `PostStatus::DRAFT->getName()` will return `"DRAFT"` .
- `PostStatus::DRAFT->getName('strtolower')` will return `"draft"` .
- `PostStatus::DRAFT->getValue()` will return `"draft"` .
- `PostStatus::DRAFT->getValue('ucfirst')` will return `"Draft"` .
- `PostStatus::names()` will return `[ "DRAFT", "UNDER_REVIEW", "PUBLISHED", ]` .
- `PostStatus::names('strtolower')` will return `[ "draft", "under_review", "published", ]` .
- `PostStatus::values()` will return `[ "draft", "under_review", "published", ]` .
- `PostStatus::values('ucfirst')` will return `[ "Draft", "Under_review", "Published", ]` .
- `PostStatus::kvPair()` will return `[ "draft" => "DRAFT", "under_review" => "UNDER_REVIEW", "published" => "PUBLISHED", ]` .
- `PostStatus::kvPair(nameCallback: 'strtolower')` will return `[ "draft" => "draft", "under_review" => "under_review", "published" => "published", ]` .
- `PostStatus::kvPair(valueCallback: 'ucfirst')` will return `[ "Draft" => "DRAFT", "Under_review" => "UNDER_REVIEW", "Published" => "PUBLISHED", ]` .
- `PostStatus::kvPair(valueAsKey: false)` will return `[ "DRAFT" => "draft", "UNDER_REVIEW" => "under_review", "PUBLISHED" => "published", ]`in **\['NAME\_OF\_ENUM' =&gt; 'VALUE\_OF\_ENUM'\]** format.

Issues?
=======

[](#issues)

If you find any issue/bug/missing feature, please submit an issue and PRs if possible.

###  Health Score

28

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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

1399d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7180f132fd7bfbbec2083528838f87996e01a6165ef50e58e2f3fcfccda1a834?d=identicon)[ssi-anik](/maintainers/ssi-anik)

---

Top Contributors

[![ssi-anik](https://avatars.githubusercontent.com/u/2676602?v=4)](https://github.com/ssi-anik "ssi-anik (10 commits)")

---

Tags

enumenumerationkvpairphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/anik-php-enum-enhancements/health.svg)

```
[![Health](https://phpackages.com/badges/anik-php-enum-enhancements/health.svg)](https://phpackages.com/packages/anik-php-enum-enhancements)
```

###  Alternatives

[mautic/grapes-js-builder-bundle

GrapesJS Builder with MJML support for Mautic

5681.4k4](/packages/mautic-grapes-js-builder-bundle)[dotty/dotty

Easy access to array data using dot notation

1293.7k1](/packages/dotty-dotty)

PHPackages © 2026

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