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

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

typiqally/enum
==============

PHP Enum Types

1.0-alpha2(5y ago)0113GPL-3.0-or-laterPHPPHP ^7.4 || ^8.0

Since Nov 5Pushed 5y ago1 watchersCompare

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

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

PHP Enum Types
==============

[](#php-enum-types)

In the current version of PHP, `enum` types are not supported. This package will introduce the `enum` type into PHP. The use-case is built around Java Enum Types. An enum type is a special data type that enables for a variable to be a set of predefined constants. The variable must be equal to one of the values that have been predefined for it.

Note
----

[](#note)

This project is currently under development and still in an alpha stage.

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

[](#installation)

The package can be installed by executing the following command:

```
composer require typiqally/enum

```

Basic
-----

[](#basic)

Basic enums can be created like this:

```
use Typiqally\Enum\Enum;

/**
 * @method static self NORTH()
 * @method static self EAST()
 * @method static self SOUTH()
 * @method static self WEST()
 */
class Direction extends Enum
{
}
```

### Usage

[](#usage)

And this is how they are used:

```
public function walk(Direction $direction): void {
    //Walk logic
}

$this->walk(Direction::NORTH());
```

Values
------

[](#values)

Enum constants can have a `mixed` value, this means it can have dynamic values like Java Enum Types. Values are assigned like this:

```
use Typiqally\Enum\Enum;

/**
 * @method static self NORTH()
 * @method static self EAST()
 * @method static self SOUTH()
 * @method static self WEST()
 */
class Direction extends Enum
{
    protected static function values(): array
    {
        return [
            'NORTH' => [
                'degrees' => 0 | 360
            ],
            'EAST' => [
                'degrees' => 90
            ],
            'SOUTH' => [
                'degrees' => 180
            ],
            'WEST' => [
                'degrees' => 270
            ]
        ];
    }

    public function getDegrees(): int
    {
        return $this->value['degrees'];
    }
}
```

### Usage

[](#usage-1)

And this is how they are used:

```
public function walk(Direction $direction): void {
    $degrees = $direction->getDegrees();
}

$this->walk(Direction::NORTH());
```

License
-------

[](#license)

This project is licensed under the GPL-3.0 license. See [LICENSE.md](https://github.com/Typiqally/enum/blob/master/LICENSE.md) for the full license text.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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 ~88 days

Total

2

Last Release

1932d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/22e14f0405d24e225a2117e0d079f1c812b2d2c5aa6839af8bd0b37cf7dc4ff0?d=identicon)[Typically](/maintainers/Typically)

---

Top Contributors

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

---

Tags

enumphpphp-libraryenumenumerabletypiqally

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/typiqally-enum/health.svg)](https://phpackages.com/packages/typiqally-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)
