1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace app\common\Enum;
- /**
- * 全局状态枚举
- */
- class StatusEnum
- {
- const ENABLED = 1; // 开启
- const DISABLED = 0; // 关闭
- const YES = 1; // 是
- const NO = 0; // 否
- public static function getYesNoMap()
- {
- return [
- self::YES => '是',
- self::NO => '否',
- ];
- }
- /**
- * 获取状态描述
- * @param int $status
- * @return string
- */
- public static function getStatusText($status)
- {
- $map = [
- self::ENABLED => '开启',
- self::DISABLED => '关闭',
- ];
- return $map[$status] ?? '未知';
- }
- /**
- * 获取状态映射
- * @return array
- */
- public static function getMap()
- {
- return [
- self::ENABLED => '开启',
- self::DISABLED => '关闭',
- ];
- }
- const NORMAL = 'normal'; // 正常
- const HIDDEN = 'hidden'; // 隐藏
- /**
- * 获取状态描述
- * @param int $status
- * @return string
- */
- public static function getStrStatusText($status)
- {
- $map = [
- self::NORMAL => '正常',
- self::HIDDEN => '隐藏',
- ];
- return $map[$status] ?? '未知';
- }
- /**
- * 获取状态映射
- * @return array
- */
- public static function getStrMap()
- {
- return [
- self::NORMAL => '正常',
- self::HIDDEN => '隐藏',
- ];
- }
- }
|