Passed
Push — master ( b979a3...edb5ad )
by ma
03:05
created
src/Provider/BaseProvider.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
      * @param array $params
24 24
      * @return mixed
25 25
      */
26
-    public function __call(string $shortcut, array $params=[])
26
+    public function __call(string $shortcut, array $params = [])
27 27
     {
28
-        $class = str_replace('Provider','Service',static::class).'\\' . Str::studly($shortcut);
29
-        if(!class_exists($class)){
28
+        $class = str_replace('Provider', 'Service', static::class) . '\\' . Str::studly($shortcut);
29
+        if (!class_exists($class)) {
30 30
             throw new TException("Chinaums:{$class}类不存在");
31 31
         }
32 32
 
33
-        return new $class($this->config,$params[0]??[]);
33
+        return new $class($this->config, $params[0] ?? []);
34 34
     }
35 35
 
36 36
     /**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function callback($contents)
41 41
     {
42
-        $params = array_map(function ($value) {
42
+        $params = array_map(function($value) {
43 43
             return urldecode($value);
44 44
         }, $contents);
45 45
         $md5Key = $this->config['md5key'];
Please login to merge, or discard this patch.
src/Service/Common/Base.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
      * @param $config
44 44
      * @param $params
45 45
      */
46
-    public function __construct($config=[],$params=[])
46
+    public function __construct($config = [], $params = [])
47 47
     {
48
-        if(!empty($config)){
48
+        if (!empty($config)) {
49 49
             $this->config = $config;
50 50
             $this->loadConfigGateway();
51 51
         }
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
      */
59 59
     private function loadConfigGateway()
60 60
     {
61
-        $gateway = $this->config['gateway'];// 正式环境
62
-        if($this->config['sandbox'] === false){
63
-            $this->gateway = isset($gateway[$this->gateway_type]) ? $gateway[$this->gateway_type] : $gateway['default'];// 沙箱环境
64
-        }else{
65
-            $this->gateway = $gateway['sandbox'];// 沙箱环境
61
+        $gateway = $this->config['gateway']; // 正式环境
62
+        if ($this->config['sandbox'] === false) {
63
+            $this->gateway = isset($gateway[$this->gateway_type]) ? $gateway[$this->gateway_type] : $gateway['default']; // 沙箱环境
64
+        } else {
65
+            $this->gateway = $gateway['sandbox']; // 沙箱环境
66 66
         }
67 67
 
68 68
         return $this;
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function request($params = [])
93 93
     {
94
-        if(!empty($params)){
94
+        if (!empty($params)) {
95 95
             $this->params = $params;
96 96
         }
97 97
 
98 98
         try {
99 99
             $data = $this->loadData();
100 100
             $sign = $this->generateSign($data);
101
-            $gateway  = $this->gateway . $this->api;
101
+            $gateway = $this->gateway . $this->api;
102 102
 
103 103
             if ('cli' == php_sapi_name()) {
104 104
                 echo 'api:' . $gateway . PHP_EOL;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
             if ('cli' == php_sapi_name()) {
121 121
                 echo $e->getMessage() . PHP_EOL;
122 122
             }
123
-            throw new TException("Chinaums request error:".$e->getMessage());
123
+            throw new TException("Chinaums request error:" . $e->getMessage());
124 124
         }
125 125
     }
126 126
 
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
     {
132 132
         try {
133 133
             $data = $this->loadData();
134
-            $params = $this->generateSign($data,true);
135
-            $gateway  = $this->gateway . $this->api;
134
+            $params = $this->generateSign($data, true);
135
+            $gateway = $this->gateway . $this->api;
136 136
 
137 137
             $data = json_encode($data);
138 138
             if ('cli' == php_sapi_name()) {
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
                 CURLOPT_TIMEOUT => 60,
145 145
                 CURLOPT_CONNECTTIMEOUT => 30
146 146
             ];
147
-            $response = Http::get($gateway,$params,$options);
147
+            $response = Http::get($gateway, $params, $options);
148 148
             return $response;
149 149
         } catch (Exception $e) {
150
-            throw new TException("Chinaums formRequest error:".$e->getMessage());
150
+            throw new TException("Chinaums formRequest error:" . $e->getMessage());
151 151
         }
152 152
     }
153 153
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
      * @param string $signType
195 195
      * @return string
196 196
      */
197
-    public function generateSign($body,$openForm=false)
197
+    public function generateSign($body, $openForm = false)
198 198
     {
199 199
         $body = (!is_string($body)) ? json_encode($body) : $body;
200 200
         $appid = $this->config['appid'];
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         $str = bin2hex(hash('sha256', $body, true));
205 205
         $signature = base64_encode(hash_hmac('sha256', "$appid$timestamp$nonce$str", $appkey, true));
206 206
         $authorization = "OPEN-BODY-SIG AppId=\"$appid\", Timestamp=\"$timestamp\", Nonce=\"$nonce\", Signature=\"$signature\"";
207
-        if($openForm){
207
+        if ($openForm) {
208 208
             $params = [
209 209
                 'appId'=>$appid,
210 210
                 'timestamp'=>$timestamp,
Please login to merge, or discard this patch.