| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace App\Module\Activity\Enums;
- use UCore\Enum\EnumCore;
- use UCore\Enum\EnumToInt;
- /**
- * 活动状态枚举
- */
- enum ACTIVITY_STATUS: int
- {
- use EnumCore, EnumToInt;
- /**
- * 未开始
- */
- case NOT_STARTED = 0;
- /**
- * 进行中
- */
- case IN_PROGRESS = 1;
- /**
- * 已结束
- */
- case ENDED = 2;
- /**
- * 已关闭
- */
- case CLOSED = 3;
- /**
- * 获取所有活动状态
- *
- * @return array
- */
- public static function getAll(): array
- {
- return [
- self::NOT_STARTED->value => '未开始',
- self::IN_PROGRESS->value => '进行中',
- self::ENDED->value => '已结束',
- self::CLOSED->value => '已关闭',
- ];
- }
- /**
- * 获取活动状态名称
- *
- * @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]);
- }
- }
|