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

ActiveLibrary

morebec/orkestra-enum
=====================

Orkestra component providing enums

v2.5.6(4y ago)1511↓100%4Apache-2.0PHPPHP &gt;=7.4

Since Apr 22Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Morebec/orkestra-enum)[ Packagist](https://packagist.org/packages/morebec/orkestra-enum)[ RSS](/packages/morebec-orkestra-enum/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelogDependencies (4)Versions (23)Used By (4)

Enum
====

[](#enum)

This Orkestra component provides typed enumerations to PHP.

Installation
------------

[](#installation)

```
composer require morebec/orkestra-orkestra-enum
```

Usage
-----

[](#usage)

### Creating an Enum

[](#creating-an-enum)

To create a new Enum, one needs to extend the `Enum` class. As an example, lets pretend we want to create a `CardinalPoint` Class. Since there are strictly 4 cardinal points, this is a good candidate for an Enum:

```
class CardinalPoint extends Enum
{
    const NORTH = 'NORTH';
    const EAST = 'EAST';
    const WEST = 'WEST';
    const SOUTH = 'SOUTH';
}
```

Simply doing this, will allow us to use our class in the following way:

```
// Instantiate a new CardinalPoint instance
$direction = new CardinalPoint(CardinalPoint::NORTH);

// Since Enums have builtin validation,
// the following line would throw an InvalidArgumentException:
$direction = new CardinalPoint('North');

// However the following would work:
$direction = new CardinalPoint('NORTH');

// Using in functions or class methods
public function changeDirection(CardinalPoint $direction)
{
    // Testing equlity with string
    if(!$direction->isEqualTo(new CardinalPoint(CardinalPoint::EAST))) {
        echo 'Not going East!';
    }

    // Since the constants are strings, it is also possible to compare
    // using loose comparison
    if($direction == CardinalPoint::NORTH) {
        echo 'Definitely going North!';
    }
}
```

> For easier IDE integration we can even go further adding `@method` annotations to the Enum class:
>
> ```
> /**
> * @method static self NORTH()
> * @method static self EAST()
> * @method static self WEST()
> * @method static self SOUTH()
> */
> class CardinalPoint extends Enum
> {
>    const NORTH = 'NORTH';
>    const EAST = 'EAST';
>    const WEST = 'WEST';
>    const SOUTH = 'SOUTH';
> }
> ```
>
>
>
> This will allow us to do the following in code:
>
> ```
> $direction = CardinalPoint::NORTH();
> ```

### Getting all possible values

[](#getting-all-possible-values)

In order to get all the possible values as an array you can use the static method `getValues`:

```
CardinalPoint::getValues();
// Returns an array as:
// [ 'NORTH', 'EAST', 'WEST', 'SOUTH' ]
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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

Every ~4 days

Total

22

Last Release

1769d ago

PHP version history (2 changes)2.0PHP &gt;=7.3

2.x-devPHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/10d7f5561446f2d4df4413803946e9f77175155d241f78bd65c0dd94e6caffc5?d=identicon)[jwillp](/maintainers/jwillp)

---

Top Contributors

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

---

Tags

enumorkestraphp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

PHPackages © 2026

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