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

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

linmad/ordinary-enum
====================

Ordinary enum type implementation for PHP

0.1(8y ago)022MITPHP

Since Jan 1Pushed 8y agoCompare

[ Source](https://github.com/LinMAD/OrdinaryEnum)[ Packagist](https://packagist.org/packages/linmad/ordinary-enum)[ Docs](https://github.com/LinMAD/OrdinaryEnum/)[ RSS](/packages/linmad-ordinary-enum/feed)WikiDiscussions master Synced 3d ago

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

OrdinaryEnum
============

[](#ordinaryenum)

```
'Ordinary' enum it's another implementation for PHP, but with one difference - simple as it's possible.

```

#### Where to and why to use

[](#where-to-and-why-to-use)

I recommend to use when need to construct some think in strict way, so for that comes Enum type. You define in some class in constructor or method a Enum class with will wait a const value form child of enum class. In that case you will control code and reduce dummy switch\\if's in your code to validate states or string values etc.

### How it works and how to use

[](#how-it-works-and-how-to-use)

Easy as possible, you crates some class and extends for Orinary's Enum class, then defines needed const values. Like that:

```
class StoreEnum extends Enum
{
  public const __default = self::GROCERY;
  public const GROCERY   = Grocery::class;
  public const COSMETIC  = Cosmetic::class;
}
```

So as you see it's easy to create list of controlled values, so it will help ya to keep cleaner your code with dependencies.

Example:

```
...
// Let's imagine you have fabric with stores
$fruitStore = $this->storeFabric()->create(StoreEnum::GROCERY);
...
// Now let's see how can be used Enum in create method
...
public function create(Enum $storeType): StoreInterface
{
  try {
    $storeType = new StoreEnum($type);
  } catch(InvalidEnumTypeException $e) {
    throw new \RuntimeException('Unable to create store from factory');
  }

   return new $storeType->getValue();
}
...
```

That's it, you define objects and provide them or handling errors, light and simple.

P.s. From me, that implementation I'm using in different web services and client library's to keep more controllable code and reduce errors with ungiven values as expected.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

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

Unknown

Total

1

Last Release

3055d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e9505df427f3614dd569fb0149bbecb4f30e175cfc9e36697d683f6e5c9e58a0?d=identicon)[LinMAD](/maintainers/LinMAD)

---

Top Contributors

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

---

Tags

dataenumlightordinaryphp7plainstructuretypetypeenumdatastructurelightordinaryPlain

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[marc-mabe/php-enum

Simple and fast implementation of enumerations with native PHP

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

Consistence - consistent approach and additions to PHP's functionality

1831.1M18](/packages/consistence-consistence)[garoevans/php-enum

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

19158.8k5](/packages/garoevans-php-enum)[graze/data-structure

Data collections and containers

12287.4k8](/packages/graze-data-structure)[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.

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

PHPackages © 2026

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