12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace app\common\Enum;
- /**
- * 全局状态枚举
- */
- class StatusEnum
- {
- const ENABLED = 1; // 开启
- const DISABLED = 0; // 关闭
- /**
- * 获取状态描述
- * @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 => '隐藏',
- ];
- }
- }
|