kalibora / labeled-enum
Enum with label that extends myclabs/php-enum
Installs: 1 983
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.1.0
- doctrine/collections: ^1.6
- myclabs/php-enum: ^1.7
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- phpstan/phpstan: ^0.12.9
- phpunit/phpunit: ^7.5
This package is auto-updated.
Last update: 2024-11-05 15:01:26 UTC
README
Enum with label that extends myclabs/php-enum.
Usage
use Kalibora\LabeledEnum\LabeledEnum; class Fruit extends LabeledEnum { private const APPLE = 1; private const ORANGE = 2; private const BANANA = 3; public static function getLabels() : array { return [ self::APPLE => 'Apple', self::ORANGE => 'Orange', self::BANANA => 'Banana', ]; } }
$orange = Fruit::ORANGE(); echo $orange->getValue(), PHP_EOL; // 2 echo $orange->getLabal(), PHP_EOL; // Orange