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

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

phpextra/enum
=============

Enum type for PHP

1.0.0(11y ago)218.4k[1 PRs](https://github.com/phpextra/enum/pulls)BSD-3-ClausePHPPHP &gt;=5.3.0

Since Aug 16Pushed 10y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (3)Used By (0)

\#Enum type

[![Latest Stable Version](https://camo.githubusercontent.com/ece3c4df382ec24e036dfecb47985a0f80ed45fa9ac61000be88ae7bda1e183c/68747470733a2f2f706f7365722e707567782e6f72672f70687065787472612f656e756d2f762f737461626c652e737667)](https://packagist.org/packages/phpextra/enum)[![Total Downloads](https://camo.githubusercontent.com/e75c709f793d1a48aa89716d54dd7c092dd057f0c1dc035e10bf980722cbd16e/68747470733a2f2f706f7365722e707567782e6f72672f70687065787472612f656e756d2f646f776e6c6f6164732e737667)](https://packagist.org/packages/phpextra/enum)[![License](https://camo.githubusercontent.com/fd4bac593ca00811ebd161d3103f41b031fce4c5af0b5c41f5b315d898268db7/68747470733a2f2f706f7365722e707567782e6f72672f70687065787472612f656e756d2f6c6963656e73652e737667)](https://packagist.org/packages/phpextra/enum)[![Build Status](https://camo.githubusercontent.com/87f8b395f30b1b82426732dd80a7cc26932bcbaf7ff90535b17a8c94d9447bf8/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f70687065787472612f656e756d2e737667)](https://travis-ci.org/phpextra/enum)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/2f3d9641ac8cf0f7d47d579c0fc0bb73e16c89e413499be49df74f9816dc2283/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f70687065787472612f656e756d2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/phpextra/enum/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/cb69b5ffb37eca2fb295eb5391638953564f0a4cafa84ab1f38257634a538448/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f70687065787472612f656e756d2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/phpextra/enum/?branch=master)[![GitTip](https://camo.githubusercontent.com/0ec766cd3550cb42f0db394a3dc81c594379aba38bdca4d1b31a56d9baae78c3/687474703a2f2f696d672e736869656c64732e696f2f6769747469702f6a6b6f6275732e737667)](https://www.gittip.com/jkobus)

\##Usage

\###Enum (PHPExtra\\Type\\EnumInterface)

Create your first enum type by creating a new class:

```
class TheGuy extends Enum
{
    const _default = self::NICE_GUY;
    const SMART_GUY = 'Mike';
    const NICE_GUY = 'Rick';
}
```

Thats all.

Now you can use it:

```
$guy = new TheGuy();
echo $guy->getValue(); // returns Rick

$mike = new TheGuy(TheGuy::MIKE);
echo $mike->getValue(); // returns Mike

echo $guy->isEqual($mike); // returns false
```

If no default value will be specified, you must set it as a constructor argument. If given constructor value will be invalid, `\UnexpectedValueException` will be thrown.

Installation (Composer)
-----------------------

[](#installation-composer)

```
{
    "require": {
        "phpextra/enum":"~1.0"
    }
}
```

\##Changelog

```
No releases yet

```

\##Contributing

All code contributions must go through a pull request. Fork the project, create a feature branch, and send me a pull request. To ensure a consistent code base, you should make sure the code follows the [coding standards](http://symfony.com/doc/2.0/contributing/code/standards.html). If you would like to help take a look at the **list of issues**.

\##Requirements

```
See composer.json for a full list of dependencies.

```

\##Authors

```
Jacek Kobus -

```

License information
-------------------

[](#license-information)

```
See the file LICENSE.txt for copying permission.

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Total

2

Last Release

3909d ago

Major Versions

1.0.0 → 2.0.x-dev2015-09-03

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1527096?v=4)[Jacek](/maintainers/jkobus)[@jkobus](https://github.com/jkobus)

---

Top Contributors

[![jkobus](https://avatars.githubusercontent.com/u/1527096?v=4)](https://github.com/jkobus "jkobus (10 commits)")

---

Tags

enum

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[myclabs/php-enum

PHP Enum implementation

2.7k227.9M637](/packages/myclabs-php-enum)[dasprid/enum

PHP 7.1 enum implementation

379146.0M11](/packages/dasprid-enum)[spatie/enum

PHP Enums

84429.1M68](/packages/spatie-enum)[marc-mabe/php-enum

Simple and fast implementation of enumerations with native PHP

49444.8M97](/packages/marc-mabe-php-enum)[spatie/laravel-enum

Laravel Enum support

3655.4M31](/packages/spatie-laravel-enum)[consistence/consistence

Consistence - consistent approach and additions to PHP's functionality

1831.1M18](/packages/consistence-consistence)

PHPackages © 2026

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