bronos / php-enum
PHP Enum
Installs: 6 673
Dependents: 3
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.1
Requires (Dev)
This package is auto-updated.
Last update: 2025-03-29 00:47:52 UTC
README
Installation
composer require bronos/php-enum
Declaration
use BronOS\PhpEnum\ConstEnum; class MyEnum extends ConstEnum { private const ONE = 1; private const TWO = 2; private const THREE = 3; }
Usage
$enumOne = MyEnum::ONE(); // $enumOne->getValue() == 1 $enumTwo = MyEnum::TWO(); // $enumTwo->getValue() == 2 $enumTree = new MyEnum(3); // $enumThree->getValue() == 3 $enumOne->getOptionName() == 'ONE'; $enumOne->isEqual(1) == true; MyEnum::isValid(5) == false; new MyEnum(4); // EnumException