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

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

tailflow/enum
=============

PHP Enums

1.1(5y ago)84.4kMITPHPPHP &gt;=7.1

Since Nov 1Pushed 5y ago1 watchersCompare

[ Source](https://github.com/tailflow/enum)[ Packagist](https://packagist.org/packages/tailflow/enum)[ Docs](https://github.com/tailflow/enum)[ RSS](/packages/tailflow-enum/feed)WikiDiscussions main Synced 4d ago

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

[![Latest Version on Packagist](https://camo.githubusercontent.com/3d14998fbc161850d61777abe0f9112f9bd70e728d1bbfb05dc8ac0e039a0721/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7461696c666c6f772f656e756d2e737667)](https://packagist.org/packages/tailflow/enum)[![Build Status](https://camo.githubusercontent.com/fcc9cc637a33bd0a5c2afc1a2f3096f4c8db223b23562ba8f90e0c92c4500d54/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7461696c666c6f772f656e756d2f64656661756c74)](https://github.com/tailflow/enum/actions)

Introduction
------------

[](#introduction)

The package offers strongly typed enums in PHP. In this package, enums are always objects, never constant values on their own. This allows for proper static analysis and refactoring in IDEs.

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

[](#installation)

You can install the package via composer:

```
composer require tailflow/enum
```

Usage
-----

[](#usage)

Here is how enums are defined:

```
use Tailflow\Enum\Enum;

class Status extends Enum
{
    public const Inactive = 0;
    public const Active = 1;
    public const OnHold = 3;
}
```

This is how they are used:

```
$class->setStatus(Status::Inactive);
```

### Custom enum labels

[](#custom-enum-labels)

By default, enum labels are derived from the constant names. To get enum label, you can use `::getLabel` method on enum class:

```
// $label will be equal to "OnHold" - the name of the constant
$label = Status::getLabel(Status::OnHold);
```

Optionally, you can provide a different label for any given enum value:

```
use Tailflow\Enum\Enum;

class Status extends Enum
{
    public const Inactive = 0;
    public const Active = 1;
    public const OnHold = 3;

    public static function labels(): array
    {
        return [
            self::OnHold => 'waiting'
        ];
    }
}

// $label will be equal to "waiting" - the custom label defined in "labels" method
$label = Status::getLabel(Status::OnHold);
```

Listing all enum labels
-----------------------

[](#listing-all-enum-labels)

To get a list of all labels of the enum, you can use `::getLabels` method:

```
// $labels will contain the array - ['Inactive', 'Active', 'waiting']
$labels = Status::getLabels();
```

Listing all enum values
-----------------------

[](#listing-all-enum-values)

To get a list of all values of the enum, you can use `::getValues` method:

```
// $labels will contain the array - [0, 1, 3]
$labels = Status::getValues();
```

License
-------

[](#license)

The Laravel Orion is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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

Every ~2 days

Total

3

Last Release

2017d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

enumenumerabletailflow

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[myclabs/php-enum

PHP Enum implementation

2.7k227.9M637](/packages/myclabs-php-enum)[spatie/enum

PHP Enums

84429.1M68](/packages/spatie-enum)[dasprid/enum

PHP 7.1 enum implementation

379146.0M11](/packages/dasprid-enum)[marc-mabe/php-enum

Simple and fast implementation of enumerations with native PHP

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

Laravel Enum support

3655.4M31](/packages/spatie-laravel-enum)[consistence/consistence

Consistence - consistent approach and additions to PHP's functionality

1831.1M18](/packages/consistence-consistence)

PHPackages © 2026

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