kalibora / labeled-enum
扩展myclabs/php-enum的带标签的枚举
v0.2.0
2020-02-05 05:00 UTC
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-09-05 14:37:07 UTC
README
扩展myclabs/php-enum的带标签的枚举。
用法
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