Download the PHP package pit-tech/v-enum without Composer
On this page you can find all versions of the php package pit-tech/v-enum. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package v-enum
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:
-
Creating Enums with Metadata:
- Each enum element can be enriched with values (payload, label, tags, and active status).
- For example, in the
Animalsenum, each element (e.g.,LEO,JAGUAR) has a unique identifier (payload) and a set of tags that allow grouping elements by specific criteria.
-
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).
- The library allows filtering enum elements by tags. For example, you can retrieve only those elements that belong to the "cats" category (
-
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.
-
Searching and Transforming Values:
- The library provides methods for searching values by identifiers and transforming arrays of identifiers into corresponding enum values.
- 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
Example of Usage:
- In this example, an
Animalsenum is created, where each element has a unique identifier (e.g.,123forLEO) and a set of tags (e.g.,CATSandHAS_MANE).
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.