PHPackages                             pkly/enum-attribute-utils - 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. pkly/enum-attribute-utils

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

pkly/enum-attribute-utils
=========================

Helper for easy attribute load/cache/fetch etc. in PHP Enums

1.1.0(4mo ago)0310↓41.3%MITPHPPHP &gt;=8.4

Since Jan 27Pushed 4mo agoCompare

[ Source](https://github.com/pkly/enum-attribute-utils)[ Packagist](https://packagist.org/packages/pkly/enum-attribute-utils)[ RSS](/packages/pkly-enum-attribute-utils/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (5)Versions (4)Used By (0)

Enum Attribute Utils
====================

[](#enum-attribute-utils)

Helper for easy attribute load/cache/fetch etc. in PHP Enums

[![Packagist Downloads](https://camo.githubusercontent.com/6b1d2baa2b1f2c570c142eab1250406c98db33624876cb06d12d8c58017de4fa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706b6c792f656e756d2d6174747269627574652d7574696c73)](https://packagist.org/packages/pkly/enum-attribute-utils)

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

[](#installation)

Simply run

```
composer require pkly/enum-attribute-utils

```

Usage
-----

[](#usage)

Example use on an enum.

```
use Pkly\EnumAttributeUtils\AttributeControlTrait;

enum ExampleEnum
{
    use AttributeControlTrait;

    #[NotAllowed]
    case Foo;

    #[CustomStuff(true)]
    case Bar;

    /**
     * @return list
     */
    public static function getNotAllowed(): array
    {
        return self::findCases(NotAllowed::class);
    }

    public function isNotAllowed(): bool
    {
        return self::attributeExists(NotAllowed::class, $this);
    }

    public function getCustom(): CustomStuff|null
    {
        return self::findAttribute(CustomStuff::class, $this);
    }

    public function getCustomWithTrue(): CustomStuff|null
    {
        return self::findAttribute(CustomStuff::class, $this, static fn (CustomStuff $s) => $s->thing);
    }
}
```

See the trait for more methods. You can use the `$filter` parameter to better revise results, so that you don't have to create multiple classes to gain the same functionality.

Attributes are preloaded once per enum and stored in AttributeCache.

It's not suggested to touch said class, it's required as enums cannot contain properties.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance77

Regular maintenance activity

Popularity15

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

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

Total

2

Last Release

127d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0642c17604cd51622ad504c999eb75ba78e5768bfa998eaa2922366fc90f0302?d=identicon)[pkly](/maintainers/pkly)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/pkly-enum-attribute-utils/health.svg)

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

###  Alternatives

[jmikola/geojson

GeoJSON implementation for PHP

3069.6M90](/packages/jmikola-geojson)

PHPackages © 2026

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