From aeb3d5a7435cf7483ea00e9b0a8ac7074e3af906 Mon Sep 17 00:00:00 2001 From: zhouyangyang Date: Sun, 10 Apr 2022 16:46:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/Commands/stubs/message.stub | 2 +- .../InvalidMobileNumberException.php | 9 +--- src/Sms.php | 14 +++++ src/SmsManager.php | 51 ++++++++++++------- 5 files changed, 52 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 61a0911..1da5e13 100644 --- a/README.md +++ b/README.md @@ -451,7 +451,7 @@ Sms::to($request->user()) 如果你希望你的短信类始终使用队列,您可以给短信消息类实现 `Zyimm\Contract\ShouldQueue` 接口,现在即使你调用了 `send` 方法,短信依旧使用队列的方式发送。另外,如果需要将短信推送到指定队列,可以设置在短信消息类中设置 `queue` 属性。 ```php -use Zyimm\Contract\ShouldQueue; +use HyperfExt\Contract\ShouldQueue; use zyimm\Sms\Smsable; class VerificationCode extends Smsable implements ShouldQueue diff --git a/src/Commands/stubs/message.stub b/src/Commands/stubs/message.stub index 2bbfd00..523b15d 100644 --- a/src/Commands/stubs/message.stub +++ b/src/Commands/stubs/message.stub @@ -10,7 +10,7 @@ declare(strict_types=1); */ namespace %NAMESPACE%; -use Zyimm\Sms\Contract\ShouldQueue; +use HyperfExt\Contract\ShouldQueue;; use Zyimm\Sms\Contracts\SenderInterface; use Zyimm\Sms\Smsable; diff --git a/src/Exceptions/InvalidMobileNumberException.php b/src/Exceptions/InvalidMobileNumberException.php index 7b0c0c5..8cfd573 100644 --- a/src/Exceptions/InvalidMobileNumberException.php +++ b/src/Exceptions/InvalidMobileNumberException.php @@ -1,17 +1,12 @@ {$method}(...$args); } + /** + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ public static function sender(string $name): PendingSms { return (new PendingSms(static::getManager()))->sender($name); } + /** + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ protected static function getManager() { return ApplicationContext::getContainer()->get(SmsManagerInterface::class); diff --git a/src/SmsManager.php b/src/SmsManager.php index 9ba7185..7a209c1 100644 --- a/src/SmsManager.php +++ b/src/SmsManager.php @@ -1,20 +1,18 @@ queue(); } @@ -101,24 +112,30 @@ class SmsManager implements SmsManagerInterface } /** - * @param \Zyimm\Sms\Contract\HasMobileNumber|string $number + * @param HasMobileNumber|string $number * @param null|int|string $defaultRegion * - * @throws \Zyimm\Sms\Exceptions\InvalidMobileNumberException + * @throws InvalidMobileNumberException */ public function to($number, $defaultRegion = null): PendingSms { return (new PendingSms($this))->to($number, $defaultRegion); } + /** + * applyStrategy + * + * @param SmsableInterface $smsable + * @return array + */ protected function applyStrategy(SmsableInterface $smsable): array { $senders = (is_array($smsable->senders) && count($smsable->senders) > 0) ? $smsable->senders : ( - is_array($this->config['default']['senders']) - ? $this->config['default']['senders'] - : [$this->config['default']['senders']] + is_array($this->config['default']['senders']) + ? $this->config['default']['senders'] + : [$this->config['default']['senders']] ); if (empty($senders)) {