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

ActiveLibrary

salekur/enum
============

A powerful tool for creating and managing enumerations.

1.0.2(1y ago)0831MITPHPPHP &gt;=7.4

Since Jun 25Pushed 1y ago1 watchersCompare

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

READMEChangelog (3)DependenciesVersions (4)Used By (0)

Laravel Enum
============

[](#laravel-enum)

A robust and flexible package for creating enumerations in Laravel. This package simplifies the creation and management of enumerated types, offering a consistent and extensible approach to handle options and their corresponding labels.

Features
--------

[](#features)

- **Automatic Label Generation**: Automatically generates human-readable labels from enumeration keys.
- **Custom Label Support**: Allows for custom labels through a static `values` method.
- **Option Retrieval**: Provides methods to retrieve all options, specific options by key, and check the existence of options.
- **Key and Label Extraction**: Easily extract all keys or labels from the enumeration.

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

[](#installation)

To install the package, use Composer:

```
composer require salekur/enum
```

Usage
-----

[](#usage)

Extend the **Enum** class and define constants for each enumerated value to create a new enumeration. Optionally, provide a **values** method to customize labels.

```
namespace Salekur\Enum\Enum;

class UserRole extends Enum {
    const ADMIN = 'admin';
    const EDITOR = 'editor';
    const VIEWER = 'viewer';

    // optional values function
    public static function values(): array {
        return [
            self::ADMIN => 'Administrator',
            self::EDITOR => 'Content Editor',
            self::VIEWER => 'Content Viewer'
        ];
    }
}
```

Retrieving Options
------------------

[](#retrieving-options)

The **Enum** class provides several methods to retrieve and interact with enumeration options. These methods allow you to access all enumeration options easily, specify option labels, check for the existence of an option, and extract keys and labels. Below are examples demonstrating how to use these methods with the UserRole enum.

```
$options = UserRole::options();
// ['admin' => 'Administrator', 'editor' => 'Content Editor', 'viewer' => 'Content Viewer']

$label = UserRole::get('admin');
// 'Administrator'

$exists = UserRole::has('editor');
// true

$keys = UserRole::keys();
// ['admin', 'editor', 'viewer']

$labels = UserRole::labels();
// ['Administrator', 'Content Editor', 'Content Viewer']
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.9% 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 ~0 days

Total

3

Last Release

692d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1454a66628c66bee7545e2bf31355e417fd3ef7289c0c7d43e3eeef308a82ce6?d=identicon)[Salekur](/maintainers/Salekur)

---

Top Contributors

[![SalekurPolas](https://avatars.githubusercontent.com/u/37521284?v=4)](https://github.com/SalekurPolas "SalekurPolas (8 commits)")[![maruf-abd](https://avatars.githubusercontent.com/u/118643987?v=4)](https://github.com/maruf-abd "maruf-abd (1 commits)")

---

Tags

enumlaravelphpphplaravelenum

### Embed Badge

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

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

###  Alternatives

[lazerg/laravel-enum-pro

A powerful PHP enum extension with collection support, random selection, and magic static calls

4319.0k](/packages/lazerg-laravel-enum-pro)[azimkordpour/power-enum

This light package provides some methods to your Enum classes to make the most of them.

4115.6k2](/packages/azimkordpour-power-enum)[mindtwo/native-enum

Package for using native php enums.

2626.0k1](/packages/mindtwo-native-enum)[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2516.7k](/packages/iteks-laravel-enum)[octw/aramex

A Library to integrate with Aramex APIs

2925.2k](/packages/octw-aramex)

PHPackages © 2026

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