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

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

kdabrow/enum-settings
=====================

Extend your enums by settings provided by attributes

1.0.0(2y ago)15MITPHPPHP &gt;=8.1CI passing

Since Dec 13Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/karoldabro/enum-settings)[ Packagist](https://packagist.org/packages/kdabrow/enum-settings)[ RSS](/packages/kdabrow-enum-settings/feed)WikiDiscussions master Synced 2d ago

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

Enum settings
=============

[](#enum-settings)

Extend your enums by settings provided by attributes.

Sponsored by [Givore](https://givore.com) and [Mistflare](https://mistflare.studio)

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

[](#installation)

```
composer require kdabrow/enum-settings
```

How to use it
-------------

[](#how-to-use-it)

### Prepare enum

[](#prepare-enum)

Add trait UseAttributeSettings to your enum and implement attribute to enum's cases. It's possible to use multiple attributes.

```
use \Kdabrow\EnumSettings\UseAttributeSettings;

enum Countries
{
    use UseAttributeSettings;

    #[CountrySettings('polish', 38)]
    case poland;

    #[CountrySettings('spanish', 47)]
    case spain;
}
```

Your attribute class might look like this. Name should end with 'Settings' but it is customizable.

```
#[\Attribute]
class CountrySettings
{
    public function __construct(
        public readonly string $language,
        public readonly int $population,
    ) {}
}
```

### Usage

[](#usage)

Get all available settings

```
Countries::poland->getSettings();

// return array with all settings
[
    'language' => 'polish',
    'population' => 38,
]
```

Get one setting

```
Countries::poland->getSetting('population');

// return value of population setting
38
```

### Customisation

[](#customisation)

It's possible to set up attribute name. For example, you have attributes: Details and Cities

```
use \Kdabrow\EnumSettings\UseAttributeSettings;

enum Countries
{
    use UseAttributeSettings;

    public function settingsAttributeName()
    {
        return [Details::class, Cities::class];
    }

    #[Details('polish', 38)]
    #[Cities('Warsaw', 'Cracow', 'Gdansk')]
    case poland;

    #[Details('spanish', 47)]
    #[Cities('Madrid', 'Barcelona', 'Valencia')]
    case spain;
}
```

Testing
-------

[](#testing)

```
vendor/bin/phpunit
```

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance60

Regular maintenance activity

Popularity5

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

Unknown

Total

1

Last Release

934d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/49186?v=4)[kdabrow](/maintainers/kdabrow)[@kdabrow](https://github.com/kdabrow)

---

Top Contributors

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

---

Tags

enumphpsettingsutilitiesphpSettingsenumattributesextend

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[ducks-project/spl-types

Polyfill Module for SplType PHP extension. This extension aims at helping people making PHP a stronger typed language and can be a good alternative to scalar type hinting. It provides different typehandling classes as such as integer, float, bool, enum and string

1033.1k](/packages/ducks-project-spl-types)

PHPackages © 2026

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