PHPackages                             dkd/enumeration - 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. dkd/enumeration

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

dkd/enumeration
===============

An enumeration implementation for PHP.

0.1(11y ago)054.7k↓22.9%7GPL-2.0PHPPHP &gt;=5.3

Since Aug 28Pushed 4y ago16 watchersCompare

[ Source](https://github.com/dkd/enumeration)[ Packagist](https://packagist.org/packages/dkd/enumeration)[ Docs](https://github.com/dkd/enumeration)[ RSS](/packages/dkd-enumeration/feed)WikiDiscussions master Synced 1mo ago

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

PHP Enumeration
===============

[](#php-enumeration)

This is a native PHP implementation to add enumeration support to PHP &gt;= 5.3. It's an abstract class that needs to be extended to use it.

Usage
=====

[](#usage)

Basics
------

[](#basics)

```
use Dkd\Enumeration;

class MyEnumeration extends Enumeration
{
    // this is optional. The value will be used as default value if no value
    // is given.
    const __DEFAULT = self::INTEGER_VALUE;

    // all scalar datatypes are supported
    const INTEGER_VALUE = 1;
    const FLOAT_VALUE = 0.123;
    const STRING_VALUE = 'foo';
    const BOOLEAN_VALUE = true;
}

// Use the ```__DEFAULT``` value if defined. If not defined an exception
// is thrown.
$myEnumeration = MyEnumeration();

$myEnumeration = new MyEnumeration(MyEnumeration::INTEGER_VALUE);

// cast does automatically cast the given value to the enumeration value.
$myEnumeration = MyEnumeration::cast(MyEnumeration::INTEGER_VALUE);
$myEnumeration = MyEnumeration::cast($myEnumeration);
$myEnumeration = MyEnumeration::cast($databaseResult['my_column']);

// get all possible values of the enumeration.
$possibleValues = MyEnumeration::getConstants();

$myEnumeration = new MyEnumeration(MyEnumeration::INTEGER_VALUE);
$myEnumeration->equals(1); // TRUE
$myEnumeration->equals($myEnumeration); // TRUE
$myEnumeration->equals(0.123); // FALSE
$myEnumeration->equals('foo'); // FALSE
$myEnumeration->equals(new MyEnumeration('foo')); // FALSE

```

Why not `SplEnum`
=================

[](#why-not-splenum)

- `SplEnum` is not build-in into PHP and requires pecl extension installed.

Install
=======

[](#install)

Composer
--------

[](#composer)

Add `dkd/enumeration` to the project's composer.json dependencies and run `php composer.phar install`

GIT
---

[](#git)

`git clone git://github.com/dkd/enumeration.git`

ZIP / TAR
---------

[](#zip--tar)

Download the last version from [Github](https://github.com/dkd/enumeration/tags)and extract it.

License
=======

[](#license)

This code is also part of the TYPO3 CMS project and has been extracted to this package. See LICENSE for details.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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

4282d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/65bbe8d95947658a4961afd1655306d6dbf5666b3696729d16f7e5fab0569d92?d=identicon)[dkd](/maintainers/dkd)

![](https://www.gravatar.com/avatar/8cab5b9422e572cf6a157fd040d217f3a8137bff045a8eae6fe42af51f13104d?d=identicon)[sascha.egerer](/maintainers/sascha.egerer)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![dkd-dobberkau](https://avatars.githubusercontent.com/u/9196831?v=4)](https://github.com/dkd-dobberkau "dkd-dobberkau (1 commits)")

---

Tags

typeenumenumeration

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/dkd-enumeration/health.svg)

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

###  Alternatives

[marc-mabe/php-enum

Simple and fast implementation of enumerations with native PHP

49644.8M97](/packages/marc-mabe-php-enum)[consistence/consistence

Consistence - consistent approach and additions to PHP's functionality

1831.1M18](/packages/consistence-consistence)[cerbero/enum

Zero-dependencies package to supercharge enum functionalities.

359207.5k2](/packages/cerbero-enum)[garoevans/php-enum

Convenient way to always have an Enum object available and utilise Spl Types if available.

19158.8k5](/packages/garoevans-php-enum)[cerbero/laravel-enum

Laravel package to supercharge enum functionalities.

18989.6k](/packages/cerbero-laravel-enum)[emreyarligan/enum-concern

A PHP package for effortless Enumeration handling with Laravel Collections 📦 ✨

21156.3k1](/packages/emreyarligan-enum-concern)

PHPackages © 2026

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