| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace App\Module\Activity\Enums;
- /**
- * 奖励状态枚举
- */
- class REWARD_STATUS
- {
- /**
- * 未领取
- */
- const NOT_CLAIMED = 0;
- /**
- * 已领取
- */
- const CLAIMED = 1;
- /**
- * 已过期
- */
- const EXPIRED = 2;
- /**
- * 获取所有奖励状态
- *
- * @return array
- */
- public static function getAll(): array
- {
- return [
- self::NOT_CLAIMED => '未领取',
- self::CLAIMED => '已领取',
- self::EXPIRED => '已过期',
- ];
- }
- /**
- * 获取奖励状态名称
- *
- * @param int $status
- * @return string
- */
- public static function getName(int $status): string
- {
- return self::getAll()[$status] ?? '未知状态';
- }
- /**
- * 检查奖励状态是否有效
- *
- * @param int $status
- * @return bool
- */
- public static function isValid(int $status): bool
- {
- return isset(self::getAll()[$status]);
- }
- }
|