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

ActiveLibrary

kambo/enum
==========

Simple enumeration library

02.7k1PHP

Since Nov 27Pushed 9y ago1 watchersCompare

[ Source](https://github.com/kambo-1st/Enum)[ Packagist](https://packagist.org/packages/kambo/enum)[ RSS](/packages/kambo-enum/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (1)

Kambo PHP enum library
======================

[](#kambo-php-enum-library)

[![Build Status](https://camo.githubusercontent.com/32a250986072b1fe276cbe751942b9f8d64eafdc3400b401089e54169e9b9f9d/68747470733a2f2f7472617669732d63692e6f72672f6b616d626f2d3173742f456e756d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kambo-1st/Enum)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/dcb3ae060b782b1d143b9ac56d4dc69fd056a9fce5dd0b1dbc8598df7b861601/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b616d626f2d3173742f456e756d2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kambo-1st/Enum/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/759bb39ac3612bb41ab4ffbdfbfa64fe6e77a3e7e1d36ab1e42e37050e94351c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6b616d626f2d3173742f456e756d2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/kambo-1st/Enum/)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

Just another PHP enumeration library

Install
-------

[](#install)

Prefered way to install library is with composer:

```
composer require kambo/enum
```

Usage
-----

[](#usage)

Enumeration is declared by implementing class `Kambo\Enum\Enum` and adding class constants:

```
use Kambo\Enum\Enum;

class Foo extends Enum {
    const BAR = 'bar';
    const QUX = 'qux';
}
```

Base enum class implement following usefull methods:

`toArray` convert whole enumeration to array with constant name in key and Enum instance in value

Following example code:

```
$array = Foo::toArray();
var_dump($array);
```

Will print:

```
array(2) {
  'BAR' =>
  string(3) "bar"
  'QUX' =>
  string(3) "qux"
}
```

There is also alias method called `values` which just called `toArray` method.

`inEnum` check if the provided value is in enumeration:

```
$existInEnum = Foo::inEnum('bar');
// print true as the value exists in enumeration
echo $existInEnum;

$existInEnum = Foo::inEnum('agh');
// print false as the value does not exists in enumeration
echo $existInEnum;
```

License
-------

[](#license)

The MIT License (MIT),

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

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/b87557270e483a60dafa29bf9c894b00b6e375439cae8f27091352b9cfcda173?d=identicon)[kambo](/maintainers/kambo)

---

Top Contributors

[![kambo-1st](https://avatars.githubusercontent.com/u/6493048?v=4)](https://github.com/kambo-1st "kambo-1st (5 commits)")

### Embed Badge

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

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

PHPackages © 2026

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