UserEnum.php 707 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\common\Enum;
  3. /**
  4. * 全局状态枚举
  5. */
  6. class UserEnum
  7. {
  8. const GENDER_MALE = 1; // 男
  9. const GENDER_FEMALE = 2; // 女
  10. const GENDER_UNKNOWN = 0; // 未知
  11. public static function getGenderMap()
  12. {
  13. return [
  14. self::GENDER_MALE => '男',
  15. self::GENDER_FEMALE => '女',
  16. self::GENDER_UNKNOWN => '未知',
  17. ];
  18. }
  19. public static function getGenderText($gender)
  20. {
  21. return self::getGenderMap()[$gender] ?? '未知';
  22. }
  23. public static function getGenderList()
  24. {
  25. return [
  26. self::GENDER_MALE,
  27. self::GENDER_FEMALE,
  28. self::GENDER_UNKNOWN,
  29. ];
  30. }
  31. }