扩展组件
This commit is contained in:
parent
a34f096e9f
commit
cb8f67ad9b
|
@ -25,7 +25,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.3",
|
"php": ">=7.4",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"ext-simplexml": "*",
|
"ext-simplexml": "*",
|
||||||
"ext-swoole": ">=4.5",
|
"ext-swoole": ">=4.5",
|
||||||
|
@ -39,7 +39,8 @@
|
||||||
"hyperf/event": "~2.2.0",
|
"hyperf/event": "~2.2.0",
|
||||||
"hyperf/framework": "~2.2.0",
|
"hyperf/framework": "~2.2.0",
|
||||||
"hyperf/guzzle": "~2.2.0",
|
"hyperf/guzzle": "~2.2.0",
|
||||||
"hyperf/logger": "~2.2.0"
|
"hyperf/logger": "~2.2.0",
|
||||||
|
"hyperf/validation": "^2.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"friendsofphp/php-cs-fixer": "^3.0",
|
"friendsofphp/php-cs-fixer": "^3.0",
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
/**
|
|
||||||
* This file is part of hyperf-ext/sms.
|
|
||||||
*
|
|
||||||
* @link https://github.com/hyperf-ext/sms
|
|
||||||
* @contact eric@zhu.email
|
|
||||||
* @license https://github.com/hyperf-ext/sms/blob/master/LICENSE
|
|
||||||
*/
|
|
||||||
namespace Zyimm\Sms\Drivers;
|
namespace Zyimm\Sms\Drivers;
|
||||||
|
|
||||||
use GuzzleHttp\Exception\ClientException;
|
use GuzzleHttp\Exception\ClientException;
|
||||||
|
@ -21,7 +15,7 @@ class TwilioDriver extends AbstractDriver
|
||||||
{
|
{
|
||||||
protected const ENDPOINT_URL = 'https://api.twilio.com/2010-04-01/Accounts/%s/Messages.json';
|
protected const ENDPOINT_URL = 'https://api.twilio.com/2010-04-01/Accounts/%s/Messages.json';
|
||||||
|
|
||||||
protected $errorStatuses = [
|
protected array $errorStatuses = [
|
||||||
'failed',
|
'failed',
|
||||||
'undelivered',
|
'undelivered',
|
||||||
];
|
];
|
||||||
|
|
|
@ -10,8 +10,10 @@ declare(strict_types=1);
|
||||||
*/
|
*/
|
||||||
namespace Zyimm\Sms\Exceptions;
|
namespace Zyimm\Sms\Exceptions;
|
||||||
|
|
||||||
|
use Zyimm\Sms\Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method \Zyimm\Sms\Response getResponse()
|
* @method Response getResponse()
|
||||||
*/
|
*/
|
||||||
class RequestException extends \GuzzleHttp\Exception\RequestException
|
class RequestException extends \GuzzleHttp\Exception\RequestException
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
/**
|
|
||||||
* This file is part of hyperf-ext/sms.
|
|
||||||
*
|
|
||||||
* @link https://github.com/hyperf-ext/sms
|
|
||||||
* @contact eric@zhu.email
|
|
||||||
* @license https://github.com/hyperf-ext/sms/blob/master/LICENSE
|
|
||||||
*/
|
|
||||||
namespace Zyimm\Sms\Exceptions;
|
namespace Zyimm\Sms\Exceptions;
|
||||||
|
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
@ -15,7 +9,7 @@ use Throwable;
|
||||||
|
|
||||||
class StrategicallySendMessageException extends RuntimeException
|
class StrategicallySendMessageException extends RuntimeException
|
||||||
{
|
{
|
||||||
protected $stack = [];
|
protected array $stack = [];
|
||||||
|
|
||||||
public function __construct($message, Throwable $throwable)
|
public function __construct($message, Throwable $throwable)
|
||||||
{
|
{
|
||||||
|
@ -30,9 +24,9 @@ class StrategicallySendMessageException extends RuntimeException
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Throwable[]
|
* @return Throwable[]
|
||||||
*/
|
*/
|
||||||
public function getStack()
|
public function getStack(): array
|
||||||
{
|
{
|
||||||
return $this->stack;
|
return $this->stack;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||||
namespace Zyimm\Sms\Listeners;
|
namespace Zyimm\Sms\Listeners;
|
||||||
|
|
||||||
use Hyperf\Event\Contract\ListenerInterface;
|
use Hyperf\Event\Contract\ListenerInterface;
|
||||||
|
use Hyperf\Validation\Contract\ValidatorFactoryInterface;
|
||||||
use Hyperf\Validation\Event\ValidatorFactoryResolved;
|
use Hyperf\Validation\Event\ValidatorFactoryResolved;
|
||||||
use Zyimm\Sms\MobileNumber;
|
use Zyimm\Sms\MobileNumber;
|
||||||
use LogicException;
|
use LogicException;
|
||||||
|
@ -21,7 +22,7 @@ class ValidatorFactoryResolvedListener implements ListenerInterface
|
||||||
|
|
||||||
public function process(object $event)
|
public function process(object $event)
|
||||||
{
|
{
|
||||||
/** @var \Hyperf\Validation\Contract\ValidatorFactoryInterface $validatorFactory */
|
/** @var ValidatorFactoryInterface $validatorFactory */
|
||||||
$validatorFactory = $event->validatorFactory;
|
$validatorFactory = $event->validatorFactory;
|
||||||
|
|
||||||
$validatorFactory->extend('mobile_number', function ($attribute, $value, $parameters, $validator) {
|
$validatorFactory->extend('mobile_number', function ($attribute, $value, $parameters, $validator) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ class MobileNumber
|
||||||
/**
|
/**
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
protected $regionCodes;
|
protected array $regionCodes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new in rule instance.
|
* Create a new in rule instance.
|
||||||
|
|
|
@ -11,11 +11,11 @@ declare(strict_types=1);
|
||||||
namespace Zyimm\Sms;
|
namespace Zyimm\Sms;
|
||||||
|
|
||||||
use Hyperf\Utils\ApplicationContext;
|
use Hyperf\Utils\ApplicationContext;
|
||||||
use Zyimm\Sms\Contract\HasMailAddress;
|
use HyperfExt\Contract\HasMailAddress;
|
||||||
use Zyimm\Sms\Contracts\SmsManagerInterface;
|
use Zyimm\Sms\Contracts\SmsManagerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method static \Zyimm\Sms\PendingSms to(HasMailAddress|string $number, null|int|string $defaultRegion = null)
|
* @method static PendingSms to(HasMailAddress|string $number, null|int|string $defaultRegion = null)
|
||||||
*/
|
*/
|
||||||
class Sms
|
class Sms
|
||||||
{
|
{
|
||||||
|
@ -26,7 +26,7 @@ class Sms
|
||||||
return $instance->{$method}(...$args);
|
return $instance->{$method}(...$args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function sender(string $name)
|
public static function sender(string $name): PendingSms
|
||||||
{
|
{
|
||||||
return (new PendingSms(static::getManager()))->sender($name);
|
return (new PendingSms(static::getManager()))->sender($name);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user