flashlabs / enums
Tools to make work with PHP enums easier
Installs: 986
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 6
pkg:composer/flashlabs/enums
Requires
- php: >=8.1
Requires (Dev)
- friendsofphp/php-cs-fixer: v3.67.0
- phpstan/phpstan: 2.1.1
- phpunit/phpunit: 11.5.2
- dev-main
- v1.0.21
- v1.0.20
- v1.0.19
- v1.0.18
- v1.0.17
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-feature/renovate_friendsofphp-php-cs-fixer-3.x
- dev-feature/renovate_phpunit-phpunit-12.x
- dev-feature/renovate_phpunit-phpunit-11.x
- dev-feature/renovate_phpstan-phpstan-2.x
- dev-feature/renovate_actions-checkout-6.x
This package is auto-updated.
Last update: 2025-12-18 12:49:45 UTC
README
PHP Enums contains tools to make your work with enums easier
Requires PHP >= 8.1.0.
Available Tools
EnumValues: trait that provide::values()method returning cases' values
Installation
You can add this library as a local, per-project dependency to your project using Composer:
composer require flashlabs/enums
Docs
EnumValues supports all Enum types: Backed and Pure
For the Backed Enums values are as defined, for the Pure values are null.
Usage
Include EnumValues trait in your Enum object:
use Flashlabs\Enums\EnumValues; enum StringsEnum: string { use EnumValues; case TIRAMISU = 'Tiramisu'; case MARSHMALLOW = 'Marshmallow'; case OAT_CAKE = 'Oat cake'; }
Use ::values() straight away:
foreach (StringsEnum::values() as $value) { echo $value . PHP_EOL; } // Output: // 'Tiramisu' // 'Marshmallow' // 'Oat cake'
Issues & Propositions
You can submit issues & propositions via GH tracker: https://github.com/flashlabs/enums/issues