| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace App\Module\Sms\Enums;
- /**
- * 短信类型枚举
- */
- class Code
- {
- public static $mapMessage = [
- CODE_TYPE::REGISTER->value => \App\Module\Sms\Messages\RegisterMessage::class,
- CODE_TYPE::LOGIN->value => \App\Module\Sms\Messages\LoginMessage::class,
- CODE_TYPE::RESET_PASSWORD->value => \App\Module\Sms\Messages\ResetPasswordMessage::class,
- ];
- /**
- *
- * 获取所有类型
- *
- * @return array
- */
- public static function getAll(): array
- {
- return [
- CODE_TYPE::REGISTER->value => '注册验证码',
- CODE_TYPE::LOGIN->value => '登录验证码',
- CODE_TYPE::RESET_PASSWORD->value => '重置密码验证码',
- ];
- }
- /**
- * 获取类型对应的消息模板类
- *
- * @param CODE_TYPE $type 类型值
- * @return string|null
- */
- public static function getTemplateClass(CODE_TYPE $type): ?string
- {
- return self::$mapMessage[$type->value] ?? null;
- }
- /**
- * 验证类型是否有效
- *
- * @param CODE_TYPE $type 类型值
- * @return bool
- */
- public static function isValid(CODE_TYPE $type): bool
- {
- return isset(self::getAll()[$type->value]);
- }
- }
|