PHPackages                             patr1k/phenum - 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. patr1k/phenum

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

patr1k/phenum
=============

PHP Enumerator

v1.0(7y ago)08[3 issues](https://github.com/patr1k/phenum/issues)MITPHPPHP &gt;=5.6

Since Oct 11Pushed 7y ago1 watchersCompare

[ Source](https://github.com/patr1k/phenum)[ Packagist](https://packagist.org/packages/patr1k/phenum)[ Docs](http://github.com/patr1k/phenum)[ RSS](/packages/patr1k-phenum/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (2)Used By (0)

Phenum - PHP Enumerator as a Trait
==================================

[](#phenum---php-enumerator-as-a-trait)

How It Works
------------

[](#how-it-works)

Unlike most enumerators which use an abstract class as a domain container, Phenum is a trait which can be attached to any class where the enumerated domain is expressed as constants.

### Advantages

[](#advantages)

- By representing enums using scalar constants rather than objects, this approach is slightly faster and more memory efficient than OO-based approaches.
- Enums are more tightly coupled with the class to which they belong, which can make the code easier to read for developers who are new to your project.

### Disadvantages

[](#disadvantages)

- Without using objects to represent enums, the auto-complete feature in your IDE won't know what the possible enum values are for a given domain. You would need to know which class defines the domain values, then begin typing the domain prefix to see the possible values.

```
