Explorar el Código

refactor: 统一代码风格

runphp hace 2 semanas
padre
commit
4ae8e6ab9a
Se han modificado 9 ficheros con 32 adiciones y 19 borrados
  1. 1 0
      config.php
  2. 1 0
      info.php
  3. 1 0
      route/admin.php
  4. 3 2
      src/Config.php
  5. 5 1
      src/Controller/IndexController.php
  6. 1 0
      src/Extension.php
  7. 1 1
      src/Facade/SmsClient.php
  8. 14 13
      src/SmsClient.php
  9. 5 2
      test/SmsClientTest.php

+ 1 - 0
config.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 return [[

+ 1 - 0
info.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 return [
   'id' => 'tencentcloud_sms',

+ 1 - 0
route/admin.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 use SixShop\TencentCloudSms\Controller\IndexController;

+ 3 - 2
src/Config.php

@@ -1,10 +1,11 @@
 <?php
+
 declare(strict_types=1);
+
 namespace SixShop\TencentCloudSms;
 
 use SixShop\System\Trait\ConfigTrait;
 
-
 /**
  * @property string $secret_id
  * @property string $secret_key
@@ -21,4 +22,4 @@ class Config
     {
         return Extension::EXTENSION_ID;
     }
-}
+}

+ 5 - 1
src/Controller/IndexController.php

@@ -1,8 +1,12 @@
 <?php
+
 declare(strict_types=1);
+
 namespace SixShop\TencentCloudSms\Controller;
+
 use SixShop\TencentCloudSms\Config;
 use think\Response;
+
 use function SixShop\Core\success_response;
 
 class IndexController
@@ -14,4 +18,4 @@ class IndexController
     {
         return success_response($config->tencent_sms_templates);
     }
-}
+}

+ 1 - 0
src/Extension.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 namespace SixShop\TencentCloudSms;

+ 1 - 1
src/Facade/SmsClient.php

@@ -14,4 +14,4 @@ class SmsClient extends Facade
     {
         return TencentCloudSmsSmsClient::class;
     }
-}
+}

+ 14 - 13
src/SmsClient.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 namespace SixShop\TencentCloudSms;
@@ -50,23 +51,23 @@ class SmsClient
      * @return array
      */
     public function sendSms(
-        array|string $phoneNumberSet, 
-        string $templateId, 
-        array|string $templateParamSet, 
+        array|string $phoneNumberSet,
+        string $templateId,
+        array|string $templateParamSet,
         ?callable $next = null,
         bool $autoCheckError = true
     ): array {
         $phoneNumberSet = (array)$phoneNumberSet;
         $templateParamSet = (array)$templateParamSet;
-        
+
         if (!isset($this->templateMap[$templateId])) {
             throw new \InvalidArgumentException("template_id {$templateId} not found");
         }
-        
+
         $req = $this->getSendSmsRequest($phoneNumberSet, $templateId, $templateParamSet);
-        
+
         // 默认的发送处理函数
-        $sendHandler = function($request) {
+        $sendHandler = function ($request) {
             try {
                 $resp = $this->client->SendSms($request);
                 return json_decode($resp->toJsonString(), true);
@@ -74,7 +75,7 @@ class SmsClient
                 throw new \RuntimeException($e->getMessage(), $e->getCode(), $e);
             }
         };
-        
+
         // 如果没有中间件,直接发送
         if ($next === null) {
             $response = $sendHandler($req);
@@ -83,9 +84,9 @@ class SmsClient
             }
             return $response;
         }
-        
+
         // 包装中间件调用
-        $middleware = function($request, $checkError = true) use ($sendHandler, $autoCheckError) {
+        $middleware = function ($request, $checkError = true) use ($sendHandler, $autoCheckError) {
             $response = $sendHandler($request);
             // 只有当自动检查错误开启且中间件未显式禁用检查时才进行检查
             if ($autoCheckError && $checkError !== false) {
@@ -93,10 +94,10 @@ class SmsClient
             }
             return $response;
         };
-        
+
         // 执行中间件链
         $response = $next($req, $middleware);
-        
+
         // 确保返回的是数组
         return is_array($response) ? $response : [];
     }
@@ -120,4 +121,4 @@ class SmsClient
             }
         }
     }
-}
+}

+ 5 - 2
test/SmsClientTest.php

@@ -1,6 +1,9 @@
 <?php
+
 declare(strict_types=1);
+
 namespace SixShop\TencentCloudSms;
+
 use PHPUnit\Framework\TestCase;
 
 class SmsClientTest extends TestCase
@@ -11,9 +14,9 @@ class SmsClientTest extends TestCase
         $this->smsClient = app()->make(SmsClient::class);
     }
 
-    public function testSendSms():void
+    public function testSendSms(): void
     {
         $resp = $this->smsClient->sendSms('13724018360', '2516637', '123456');
         dump($resp);
     }
-}
+}