| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace App\Module\Sms\Messages;
- use App\Module\Sms\Gateway\MyGateway;
- use Overtrue\EasySms\Contracts\GatewayInterface;
- use Overtrue\EasySms\Gateways\SmsbaoGateway;
- use UCore\Helper\Str;
- /**
- * 注册验证码消息
- */
- class RegisterMessage extends BaseMessage
- {
- /**
- * 获取消息内容
- *
- * @param GatewayInterface|null $gateway 短信网关
- * @return string
- */
- public function getContent(GatewayInterface $gateway = null): string
- {
- if (is_null($gateway)) {
- return '';
- }
- $template = match (true) {
- $gateway instanceof MyGateway => '注册验证码:{code}',
- $gateway instanceof SmsbaoGateway => $gateway->getConfig()['register_template'] ?? '注册验证码:{code}',
- default => ''
- };
- return Str::strtr($template, $this->getData($gateway));
- }
- public function getTemplate(GatewayInterface $gateway = null)
- {
- return 'SMS_REGISTER';
- }
- public function getData(GatewayInterface $gateway = null)
- {
- return [
- 'code' => $this->data['code'],
- ];
- }
- }
|