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

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

simondeeley/enum
================

A simple ENUM object for PHP

v1.1.2(8y ago)14GPL-3.0PHPPHP ~7.1

Since Nov 25Pushed 8y ago2 watchersCompare

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

READMEChangelog (4)Dependencies (1)Versions (7)Used By (0)

ENUM object for PHP
===================

[](#enum-object-for-php)

[![License](https://camo.githubusercontent.com/933fd055420e112fa9ff7381963778738389478cbc92bc997469fe92ec03947f/68747470733a2f2f706f7365722e707567782e6f72672f73696d6f6e6465656c65792f656e756d2f6c6963656e73653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/simondeeley/enum) [![Latest Stable Version](https://camo.githubusercontent.com/b80dc4747c3bc0038e009d14154c7f164bb4752a7847a249598eae51237da7c6/68747470733a2f2f706f7365722e707567782e6f72672f73696d6f6e6465656c65792f656e756d2f762f737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/simondeeley/enum) [![Latest Unstable Version](https://camo.githubusercontent.com/efb66430bdbdf11e12811315ba7c7a39b33316e0251f622894b75675690de8e3/68747470733a2f2f706f7365722e707567782e6f72672f73696d6f6e6465656c65792f656e756d2f762f756e737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/simondeeley/enum) [![Build Status](https://camo.githubusercontent.com/87c43ada51bf8baf22a4a76f56c8fa22a3794605884997c3da57a4209109855a/68747470733a2f2f7472617669732d63692e6f72672f73696d6f6e6465656c65792f656e756d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/simondeeley/enum) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/7d8b960723c3fa3c121a17ed4ea09db9f39b38450d5c5f35e7ae75abbd4fcbcf/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73696d6f6e6465656c65792f656e756d2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/simondeeley/enum/?branch=master) [![Code Coverage](https://camo.githubusercontent.com/e595ccb02913a35434f796ea2b2aeb87b23aaff289367ff9078340684e3e79e1/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73696d6f6e6465656c65792f656e756d2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/simondeeley/enum/?branch=master)

A simple library for adding ENUM type objects into any existing or new PHP project.

Requirements
============

[](#requirements)

- PHP &gt;= 7.1

Installation
============

[](#installation)

```
composer require simondeeley/enum

```

Usage
=====

[](#usage)

Create a new Enum class using your own chosen enum types

```
use simondeeley\enum;

class MyAwesomeEnum extends Enum
{
    const FOO = 'FOO';
    const BAR = 'BAR';
}
```

Now you can use your newly designed enum object in your code. Just simply instantiate a new `MyAwesomeEnum` every time you want to use an enum. The constants you defined in the class definition determine what the allowed values of the enum object can take. You can add as many constants as you wish, depending on your design needs.

Every time a new instance of your enum object is created, it requires that you pass a value to it's constructor. If the value passed to the constructor is not one of the pre-determined values then an `InvalidArgumentException` will be thrown.

```
use Acme\MyAwesomeEnum;

$good = new MyAwesomeEnum('FOO');
$bad = new MyAwesomeEnum('BAZ'); // throws an exception
```

Examples
========

[](#examples)

This package provides two enums for out-of-the-box use, [`Boolean`](../blob/master/src/Enums/Boolean.php) and [`Weekday`](../blob/master/src/Enums/Weekday.php). The first, [`Boolean`](../blob/master/src/Enums/Boolean.php) leverages an enum that is either true or false whilst the second is a list of the days of the week.

```
use simondeeley\Enums\Boolean;
use simondeeley\Enums\Weekday;

$true = new Boolean('TRUE');
$true->getValue(); // returns (bool) true

$tuesday = new Weekday('TUESDAY');
$tuesday->getValue(); // returns (string) "Tuesday"
```

Although not mandatory when building enum objects, both [`Boolean`](../blob/master/src/Enums/Boolean.php) and [`Weekday`](../blob/master/src/Enums/Weekday.php) each provide short-cut static methods to quickly create a new object, for example:

```
$true = Boolean::true();

$saturday = Weekday::Saturday();
```

This functionality is built-in to any enums extending the base [`Enum`](../blob/master/src/Enum.php) type object. The only caveats are that when performing static method calls that it is best to keep in-line with PHP good coding practice and to ensure all constants are typed in uppercase.

###  Health Score

27

—

LowBetter than 46% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 97.3% 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 ~2 days

Total

6

Last Release

3176d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9180037508701a50d15e6806ea198a315ae0702159c9633376eaccab7e6c19e2?d=identicon)[unwarysheep](/maintainers/unwarysheep)

---

Top Contributors

[![simondeeley](https://avatars.githubusercontent.com/u/493834?v=4)](https://github.com/simondeeley "simondeeley (73 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (2 commits)")

---

Tags

enumphpphp7phpenumimmutable

### Embed Badge

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

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

###  Alternatives

[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2520.3k](/packages/iteks-laravel-enum)

PHPackages © 2026

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