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

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

ngabor84/enum
=============

Enum is a simple implementation of php enumeration type.

v0.3.2(9y ago)032MITPHPPHP ^7.0

Since Feb 13Pushed 9y agoCompare

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

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

\#Enum

[ ![Codeship Status for ngabor84/enum](https://camo.githubusercontent.com/c4f48086e09a3e1c884c47f55df516d77a2b97f5010c125d8b615881a1733280/68747470733a2f2f6170702e636f6465736869702e636f6d2f70726f6a656374732f64326563336366302d643138652d303133342d333230332d3736316439393039626663322f7374617475733f6272616e63683d6d6173746572)](https://app.codeship.com/projects/201541)

About
-----

[](#about)

Enum is a simple implementation of php's missing enumeration type.

Requirements
------------

[](#requirements)

- PHP 7.0 or above

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

[](#installation)

Install Enum via the composer package manager from packagist [ngabor84/enum](https://packagist.org/packages/ngabor84/enum).

Usage
-----

[](#usage)

```
// Define a new Enum type
class Status extends Enum {

    const ACTIVE = 'active';

    const PASSIVE = 'pasive';

}

// Use the new Status Enum type
$carStatus = new Status(Status::ACTIVE);
$carStatus->getValue(); // return 'active';

$carStatus2 = new Status();
$carStatus2->setValue(Status::PASSIVE);

if ($carStatus2->isEqualTo($carStatus)) { // it will be false
    echo "\$carStatus2 and \$carStatus has the same value";
} else { // this will be printed
    echo "\$carStatus2 and \$carStatus has different value";
    echo "\$carStatus2: $carStatus2"; // print '$carStatus2: passive'
}

Status::isValidValue('active'); // return true
Status::isValidKey('INACTIVE'); // return false
Status::getKeyByValue('passive'); // return 'PASSIVE'
Status::listOptions(); // return ['ACTIVE' => 'active', 'PASSIVE' => 'passive']
Status::listKeys(); // return ['ACTIVE', 'PASSIVE']
Status::listValues(); // return ['active', 'passive']
Status::getDefaultValue(); // return 'active' (it's the first constants value by default, but this method is also overridable)
```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

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

Total

2

Last Release

3397d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/22472700?v=4)[Gábor Németh](/maintainers/ngabor84)[@ngabor84](https://github.com/ngabor84)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[jeremytubbs/laravel-deepzoom

Laravel Deepzoom Tile Generator for OpenSeadragon

111.3k](/packages/jeremytubbs-laravel-deepzoom)

PHPackages © 2026

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