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

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

patchlevel/enum
===============

Small lightweight library to create enum in PHP without SPLEnum and strict comparisons allowed

1.0.0(5y ago)919.9k1[7 PRs](https://github.com/patchlevel/enum/pulls)MITPHPPHP ^7.4|^8.0

Since Dec 5Pushed 2y ago2 watchersCompare

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

READMEChangelog (1)Dependencies (6)Versions (10)Used By (0)

[![Mutation testing badge](https://camo.githubusercontent.com/eef1cb3c756408ef591d80317b722ddc98de3e5e3d3c6af7b46787fde365a1ec/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d25324670617463686c6576656c253246656e756d2532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/patchlevel/enum/master)[![Type Coverage](https://camo.githubusercontent.com/0f84f0739600371d7dd9701fe470366acb18325400a58e08137e9cc5c5909713/68747470733a2f2f73686570686572642e6465762f6769746875622f70617463686c6576656c2f656e756d2f636f7665726167652e737667)](https://shepherd.dev/github/patchlevel/enum)[![Latest Stable Version](https://camo.githubusercontent.com/da0eb54a0d6dc1200522209bb827ad7f26ff103355629b7422bc32518705b7ab/68747470733a2f2f706f7365722e707567782e6f72672f70617463686c6576656c2f656e756d2f76)](//packagist.org/packages/patchlevel/enum)[![License](https://camo.githubusercontent.com/fb70bf10dda603263ece29645da1d8533f0a76d7f966995e1a2dd437a03bb060/68747470733a2f2f706f7365722e707567782e6f72672f70617463686c6576656c2f656e756d2f6c6963656e7365)](//packagist.org/packages/patchlevel/enum)

enum
====

[](#enum)

Small lightweight library to create enum in PHP without SPLEnum and strict comparisons allowed.

dislcaimer
----------

[](#dislcaimer)

For project that are build on PHP &gt;=8.1 please use the language build in Enums described in this rfc: This library should not be needed anymore and will not support PHP &gt;8.1.

installation
------------

[](#installation)

```
composer require patchlevel/enum

```

declaration
-----------

[](#declaration)

First of all you have to define your enum. To do this, you have to inherit from the `Enum` class, create a few constants (the value must be unique and a string) and define methods that return an enum representation. Here is an example:

```
