gerritdrost / phenum
Because PHP needs Enums
Installs: 93 312
Dependents: 2
Suggesters: 0
Security: 0
Stars: 14
Watchers: 3
Forks: 4
Open Issues: 0
Requires
- php: >=8.1.0
Requires (Dev)
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2024-10-24 18:26:20 UTC
README
PHP has native support for enums since version 8.1. Use those if you have the chance.
phenum
Enums for PHP, nuff said.
Description
A lot of people love enums. Unfortunately, PHP does not support them out-of-the-box, it requires SplEnum
to be installed. I stumbled across this problems as well and decided to attempt to solve it: say hello to phenum.
Why phenum?
Because it's easy to use and has some cool features. Enum values are actually are singleton objects, they have their own instance and can have their own variables! Also the library provides utility classes like the EnumMap which can be used to map values to Enums, something not possible with regular PHP arrays.
Dependencies
PHP 8.1 or newer.
Setup
Include gerritdrost/phenum
using composer.