limingxinleo / x-phalcon-enum
a phalcon enum component
Installs: 4 402
Dependents: 1
Suggesters: 0
Security: 0
Stars: 10
Watchers: 4
Forks: 3
Open Issues: 0
Requires
- php: >=7.0
- limingxinleo/support-str: ^1.0
- limingxinleo/x-trait-common: ^1.1
Requires (Dev)
- phpunit/phpunit: >=5.6
Suggests
- php: >=7.0
- ext-phalcon: ^3.0
README
安装
composer require limingxinleo/x-phalcon-enum
使用
定义枚举类
use Xin\Phalcon\Enum\Enum;
class ErrorCode extends Enum
{
/**
* @Message('非法的TOKEN')
*/
public static $ENUM_INVALID_TOKEN = 700;
}
获取单个枚举
$code = ErrorCode::$ENUM_INVALID_TOKEN;
$message = ErrorCode::getMessage($code);
获取枚举数组
$message = ErrorCode::toArray();