PHPackages                             hexatex/abstractenum - 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. hexatex/abstractenum

ActiveLibrary

hexatex/abstractenum
====================

An abstract class that simulates phps missing enum

13.6kPHP

Since Mar 2Pushed 7y ago1 watchersCompare

[ Source](https://github.com/hexatex/abstractEnum)[ Packagist](https://packagist.org/packages/hexatex/abstractenum)[ RSS](/packages/hexatex-abstractenum/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (2)Used By (0)

AbstractEnum
============

[](#abstractenum)

This abstract class allows you to simulate the enum type found in many other languages.

Examples
--------

[](#examples)

```
class UtensilType extends abstractEnum
{
    const spoon = 2;
    const steakKnife = 3;
    // Or namespace them like this:
    const fork = 'UtensilType@fork';
    // ...Although if you're storing them in a database consider using numbers.
}

interface IUtensil
{
    public function getType(): UtensilType;
}

abstract class Utensil implements IUtensil
{
    //...
}

class Spoon extends Utensil
{
    public function getType(): UtensilType
    {
        return UtensilType::spoon();
    }
}

class Drawer
{
    // ...
    public function addUtensil(Utensil $utensil) {
        switch ($utensil->getType()) {
            case UtensilType::fork():
                // polish prongs...
                // place in fork slot
                break;
            case UtensilType::spoon():
                // Shine spoon on shirt
                // Place in spoon slot
                echo "Oooooo spoon so shiny";
                break;
        }
    }
}

$drawer = new Drawer;
$spoon = new Spoon;
$drawer->addUtensil($spoon);

// $drawer->grabUtensil(UtensilType::spoon());

// // UtensilType::existsOrFail('salidKnife'); // throws exception
// if (UtensilType::exists('salidKnife') == false) {
//     echo "Salad knives don't exist. \n";
// }

// print_r(UtensilType::spoon());

// echo "UtensilType::spoon()\n";

// if (UtensilType::spoon() == UtensilType::steakKnife()) // False
//     echo "UtensilType::spoon() == UtensilType::steakKnife()\n";
// if (UtensilType::steakKnife() == UtensilType::steakKnife()) // True
//     echo "UtensilType::steakKnife() == UtensilType::steakKnife()\n";

// print_r(get_class(UtensilType::steakKnife()));
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/496ce1bdc5ea9a81044b6bec5def630d050de7acc0a08dd300b0b5f88a380d8f?d=identicon)[hexatex](/maintainers/hexatex)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/hexatex-abstractenum/health.svg)

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

PHPackages © 2026

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