PHPackages                             pit-tech/v-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. pit-tech/v-enum

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

pit-tech/v-enum
===============

Enum collections helper

1.0.2(1y ago)112MITPHPPHP ^8.3

Since Feb 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/AlexPitTech/venum)[ Packagist](https://packagist.org/packages/pit-tech/v-enum)[ RSS](/packages/pit-tech-v-enum/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

### vEnum Collection

[](#venum-collection)

The **PitTech\\vEnum** library provides a convenient and powerful tool for working with enumerations (Enum, Object Constants) in PHP. It offers an interface that allows extending enums with additional metadata and managing them. The library supports filtering and transformations.

### Key Features of the Library:

[](#key-features-of-the-library)

1. **Creating Enums with Metadata:**

    - Each enum element can be enriched with values (payload, label, tags, and active status).
    - For example, in the `Animals` enum, each element (e.g., `LEO`, `JAGUAR`) has a unique identifier (payload) and a set of tags that allow grouping elements by specific criteria.
2. **Filtering Elements:**

    - The library allows filtering enum elements by tags. For example, you can retrieve only those elements that belong to the "cats" category (`CATS`).
3. **Working with Active and Inactive Elements:**

    - Enum elements can be marked as active or inactive. This is useful, for instance, when an entity type is no longer relevant but still exists in the database.
4. **Searching and Transforming Values:**

    - The library provides methods for searching values by identifiers and transforming arrays of identifiers into corresponding enum values.
5. **Flexibility in Usage:**

    - The library can work with both Enums and classic objects or interfaces where constants are used as enum elements.

### Installation via composer

[](#installation-via-composer)

```
composer require pit-tech/v-enum
```

### Example of Usage:

[](#example-of-usage)

```
enum Animals: string
{
    use EnumTrait;

    // several groups of animals
    const SPOTTED = 'spotted';
    const HAS_MANE = 'hasMane';
    const CATS = 'cats';
    const GIRAFFIDAE = 'giraffidae';

    // 123 - is external id
    #[vEnum(123, tags: [self::CATS, self::HAS_MANE])]
    case LEO = 'leo'; // 'leo' - is local unique id of animal

    #[vEnum(124, tags: [self::CATS, self::SPOTTED])]
    case JAGUAR = 'jaguar';

    #[vEnum(125, tags: [self::CATS])]
    case PANTHER = 'panther';

    // Guepard - is title of the enum value
    #[vEnum(126, title: 'Guepard', [self::CATS, self::SPOTTED])]
    case GUEPARD = 'guepard';

    #[vEnum(127, tags: [self::GIRAFFIDAE, self::SPOTTED])]
    case GIRAFFE = 'giraffe';

}
```

- In this example, an `Animals` enum is created, where each element has a unique identifier (e.g., `123` for `LEO`) and a set of tags (e.g., `CATS` and `HAS_MANE`).

```
    // get all external ids of animals belonging to the cats group and having spots
    Animals::filter([Animals::CATS, Animals::SPOTTED => true])->payloads();
    // get all external ids of animals belonging to the cats group and having spots
    Animals::filter([Animals::HAS_MANE])->values();

    // enums can be mapped with callback and transform to entries in your API
    Animals::map(fn(vEnum $vEnum) => [
        'label' => $vEnum->label ?? ucfirst($vEnum->value). ' as default',
        'value' => $vEnum->value,
    ])
}
```

### Advantages of the library:

[](#advantages-of-the-library)

- **Flexibility:** Using PHP Attributes, it allows adding additional parameters to enums.
- **Convenience:** Simplifies working with enums by providing ready-made methods for searching and filtering.
- **Integration:** Easily integrates with existing projects and testing frameworks.

The **PitTech\\vEnum** library is a powerful tool for PHP developers who want to improve the structure and readability of their code when working with enums.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance43

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

450d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ebdc206b704f5ec3fdbedaaf64d1a64f4e8686c322c6746f9f38b0e02debbf7?d=identicon)[AlexPitTech](/maintainers/AlexPitTech)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/pit-tech-v-enum/health.svg)

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

###  Alternatives

[danharrin/date-format-converter

Convert token-based date formats between standards.

3222.4M7](/packages/danharrin-date-format-converter)[corcel/acf

Advanced Custom Field (ACF) plugin for Corcel

132343.9k7](/packages/corcel-acf)[yzen.dev/plain-to-class

Class-transformer to transform your dataset into a structured object

16293.9k6](/packages/yzendev-plain-to-class)[contributte/event-dispatcher

Best event dispatcher / event manager / event emitter for Nette Framework

292.4M19](/packages/contributte-event-dispatcher)[carbon/includeassets

Include your assets (css, js) in an easy way into Neos

14228.6k10](/packages/carbon-includeassets)[havokinspiration/wrench

Maintenance mode plugin for CakePHP 3.X

2661.2k](/packages/havokinspiration-wrench)

PHPackages © 2026

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