@@ -267,7 +267,7 @@ |
||
| 267 | 267 | |
| 268 | 268 | $name = \ucfirst(\str_replace(['-', '_', ''], '', $name)); |
| 269 | 269 | |
| 270 | - return __NAMESPACE__."\\Gateways\\{$name}Gateway"; |
|
| 270 | + return __NAMESPACE__."\\Gateways\\{$name}gateway"; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @throws NoGatewayAvailableException |
| 54 | 54 | * @throws InvalidArgumentException |
| 55 | 55 | */ |
| 56 | - public function send(array|string $to, MessageInterface|array $message, array $gateways = []): array |
|
| 56 | + public function send(array | string $to, MessageInterface | array $message, array $gateways = []): array |
|
| 57 | 57 | { |
| 58 | 58 | $to = $this->formatPhoneNumber($to); |
| 59 | 59 | $message = $this->formatMessage($message); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function gateway(?string $name): GatewayInterface |
| 75 | 75 | { |
| 76 | - if (! isset($this->gateways[$name])) { |
|
| 76 | + if (!isset($this->gateways[$name])) { |
|
| 77 | 77 | $this->gateways[$name] = $this->createGateway($name); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -91,15 +91,15 @@ discard block |
||
| 91 | 91 | $strategy = $this->config->get('default.strategy', OrderStrategy::class); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if (! \class_exists($strategy)) { |
|
| 94 | + if (!\class_exists($strategy)) { |
|
| 95 | 95 | $strategy = __NAMESPACE__.'\Strategies\\'.\ucfirst($strategy); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if (! \class_exists($strategy)) { |
|
| 98 | + if (!\class_exists($strategy)) { |
|
| 99 | 99 | throw new InvalidArgumentException("Unsupported strategy \"{$strategy}\""); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - if (empty($this->strategies[$strategy]) || ! ($this->strategies[$strategy] instanceof StrategyInterface)) { |
|
| 102 | + if (empty($this->strategies[$strategy]) || !($this->strategies[$strategy] instanceof StrategyInterface)) { |
|
| 103 | 103 | $this->strategies[$strategy] = new $strategy($this); |
| 104 | 104 | } |
| 105 | 105 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | { |
| 139 | 139 | $config = $this->config->get("gateways.{$name}", []); |
| 140 | 140 | |
| 141 | - if (! isset($config['timeout'])) { |
|
| 141 | + if (!isset($config['timeout'])) { |
|
| 142 | 142 | $config['timeout'] = $this->config->get('timeout', Gateway::DEFAULT_TIMEOUT); |
| 143 | 143 | } |
| 144 | 144 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | $gateway = $this->makeGateway($className, $config); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - if (! ($gateway instanceof GatewayInterface)) { |
|
| 154 | + if (!($gateway instanceof GatewayInterface)) { |
|
| 155 | 155 | throw new InvalidArgumentException(\sprintf('Gateway "%s" must implement interface %s.', $name, GatewayInterface::class)); |
| 156 | 156 | } |
| 157 | 157 | |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | protected function makeGateway(string $gateway, array $config): GatewayInterface |
| 167 | 167 | { |
| 168 | - if (! \class_exists($gateway) || ! \in_array(GatewayInterface::class, \class_implements($gateway))) { |
|
| 168 | + if (!\class_exists($gateway) || !\in_array(GatewayInterface::class, \class_implements($gateway))) { |
|
| 169 | 169 | throw new InvalidArgumentException(\sprintf('Class "%s" is a invalid easy-sms gateway.', $gateway)); |
| 170 | 170 | } |
| 171 | 171 | |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | return \call_user_func($this->customCreators[$gateway], $config); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - protected function formatPhoneNumber(PhoneNumberInterface|string $number): PhoneNumberInterface |
|
| 197 | + protected function formatPhoneNumber(PhoneNumberInterface | string $number): PhoneNumberInterface |
|
| 198 | 198 | { |
| 199 | 199 | if ($number instanceof PhoneNumberInterface) { |
| 200 | 200 | return $number; |
@@ -203,10 +203,10 @@ discard block |
||
| 203 | 203 | return new PhoneNumber(\trim($number)); |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - protected function formatMessage(MessageInterface|array|string $message): MessageInterface |
|
| 206 | + protected function formatMessage(MessageInterface | array | string $message): MessageInterface |
|
| 207 | 207 | { |
| 208 | - if (! ($message instanceof MessageInterface)) { |
|
| 209 | - if (! \is_array($message)) { |
|
| 208 | + if (!($message instanceof MessageInterface)) { |
|
| 209 | + if (!\is_array($message)) { |
|
| 210 | 210 | $message = [ |
| 211 | 211 | 'content' => $message, |
| 212 | 212 | 'template' => $message, |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | $formatted[$gateway] = $setting; |
| 236 | 236 | $globalSettings = $this->config->get("gateways.{$gateway}", []); |
| 237 | 237 | |
| 238 | - if (\is_string($gateway) && ! empty($globalSettings) && \is_array($setting)) { |
|
| 238 | + if (\is_string($gateway) && !empty($globalSettings) && \is_array($setting)) { |
|
| 239 | 239 | $formatted[$gateway] = new Config(\array_merge($globalSettings, $setting)); |
| 240 | 240 | } |
| 241 | 241 | } |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | /** |
| 24 | 24 | * @return array |
| 25 | 25 | */ |
| 26 | - public function send(PhoneNumberInterface|array $to, MessageInterface $message, Config $config) |
|
| 26 | + public function send(PhoneNumberInterface | array $to, MessageInterface $message, Config $config) |
|
| 27 | 27 | { |
| 28 | 28 | if (is_array($to)) { |
| 29 | 29 | $to = implode(',', $to); |
@@ -23,11 +23,11 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | protected string $type; |
| 25 | 25 | |
| 26 | - protected \Closure|string|null $content = null; |
|
| 26 | + protected \Closure | string | null $content = null; |
|
| 27 | 27 | |
| 28 | - protected \Closure|string|null $template = null; |
|
| 28 | + protected \Closure | string | null $template = null; |
|
| 29 | 29 | |
| 30 | - protected array|\Closure $data = []; |
|
| 30 | + protected array | \Closure $data = []; |
|
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * Message constructor. |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | /** |
| 106 | 106 | * @return $this |
| 107 | 107 | */ |
| 108 | - public function setData(callable|array $data): static |
|
| 108 | + public function setData(callable | array $data): static |
|
| 109 | 109 | { |
| 110 | 110 | $this->data = $data; |
| 111 | 111 | |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | /** |
| 27 | 27 | * 18888888888. |
| 28 | 28 | */ |
| 29 | - public function getNumber(): int|string; |
|
| 29 | + public function getNumber(): int | string; |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * +8618888888888. |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | class PhoneNumber implements Contracts\PhoneNumberInterface |
| 24 | 24 | { |
| 25 | - protected int|string $number; |
|
| 25 | + protected int | string $number; |
|
| 26 | 26 | |
| 27 | 27 | protected ?int $IDDCode; |
| 28 | 28 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * PhoneNumberInterface constructor. |
| 35 | 35 | */ |
| 36 | - public function __construct(int|string $numberWithoutIDDCode, ?string $IDDCode = null) |
|
| 36 | + public function __construct(int | string $numberWithoutIDDCode, ?string $IDDCode = null) |
|
| 37 | 37 | { |
| 38 | 38 | $this->phoneUtil = PhoneNumberUtil::getInstance(); |
| 39 | 39 | $numberStr = (string) $numberWithoutIDDCode; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | /** |
| 92 | 92 | * 18888888888. |
| 93 | 93 | */ |
| 94 | - public function getNumber(): int|string |
|
| 94 | + public function getNumber(): int | string |
|
| 95 | 95 | { |
| 96 | 96 | return $this->number; |
| 97 | 97 | } |
@@ -14,4 +14,6 @@ |
||
| 14 | 14 | /** |
| 15 | 15 | * Class InvalidArgumentException. |
| 16 | 16 | */ |
| 17 | -class InvalidArgumentException extends Exception {} |
|
| 17 | +class InvalidArgumentException extends Exception |
|
| 18 | +{ |
|
| 19 | +} |
|
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | $params = [ |
| 54 | 54 | 'appid' => $config->get('app_id'), |
| 55 | 55 | 'signature' => $config->get('app_key'), |
| 56 | - 'project' => ! empty($template_code) ? $template_code : (! empty($data['project']) ? $data['project'] : $config->get('project')), |
|
| 56 | + 'project' => !empty($template_code) ? $template_code : (!empty($data['project']) ? $data['project'] : $config->get('project')), |
|
| 57 | 57 | 'to' => $to->getUniversalNumber(), |
| 58 | 58 | 'vars' => json_encode($data, JSON_FORCE_OBJECT), |
| 59 | 59 | ]; |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | |
| 54 | 54 | $result = $this->post(sprintf(self::ENDPOINT_TEMPLATE, 'send'), $params); |
| 55 | 55 | |
| 56 | - if (! $result['result']) { |
|
| 56 | + if (!$result['result']) { |
|
| 57 | 57 | throw new GatewayErrorException($result['message'], $result['statusCode'], $result); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | public function send(PhoneNumberInterface $to, MessageInterface $message, Config $config) |
| 61 | 61 | { |
| 62 | 62 | $data = $message->getData($this); |
| 63 | - $signName = ! empty($data['sign_name']) ? $data['sign_name'] : $config->get('sign_name'); |
|
| 64 | - $smsAccount = ! empty($data['sms_account']) ? $data['sms_account'] : $config->get('sms_account'); |
|
| 63 | + $signName = !empty($data['sign_name']) ? $data['sign_name'] : $config->get('sign_name'); |
|
| 64 | + $smsAccount = !empty($data['sms_account']) ? $data['sms_account'] : $config->get('sms_account'); |
|
| 65 | 65 | $templateId = $message->getTemplate($this); |
| 66 | - $phoneNumbers = ! empty($data['phone_numbers']) ? $data['phone_numbers'] : $to->getNumber(); |
|
| 67 | - $templateParam = ! empty($data['template_param']) ? $data['template_param'] : $message->getData($this); |
|
| 66 | + $phoneNumbers = !empty($data['phone_numbers']) ? $data['phone_numbers'] : $to->getNumber(); |
|
| 67 | + $templateParam = !empty($data['template_param']) ? $data['template_param'] : $message->getData($this); |
|
| 68 | 68 | |
| 69 | - $tag = ! empty($data['tag']) ? $data['tag'] : ''; |
|
| 69 | + $tag = !empty($data['tag']) ? $data['tag'] : ''; |
|
| 70 | 70 | |
| 71 | 71 | $payload = [ |
| 72 | 72 | 'SmsAccount' => $smsAccount, // 消息组帐号,火山短信页面右上角,短信应用括号中的字符串 |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | public function getEndpoint() |
| 200 | 200 | { |
| 201 | 201 | $regionId = $this->getRegionId(); |
| 202 | - if (! in_array($regionId, array_keys(self::$endpoints))) { |
|
| 202 | + if (!in_array($regionId, array_keys(self::$endpoints))) { |
|
| 203 | 203 | $regionId = self::ENDPOINT_DEFAULT_REGION_ID; |
| 204 | 204 | } |
| 205 | 205 | |