Completed
Push — master ( 1ec9e3...ab571a )
by Songda
03:58
created
src/Gateways/Alipay/Support.php 1 patch
Spacing   +12 added lines, -13 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     {
126 126
         Events::dispatch(Events::API_REQUESTING, new Events\ApiRequesting('Alipay', '', self::$instance->getBaseUri(), $data));
127 127
 
128
-        $data = array_filter($data, function ($value) {
128
+        $data = array_filter($data, function($value) {
129 129
             return ($value == '' || is_null($value)) ? false : true;
130 130
         });
131 131
 
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
 
135 135
         Events::dispatch(Events::API_REQUESTED, new Events\ApiRequesting('Alipay', '', self::$instance->getBaseUri(), $result));
136 136
 
137
-        $method = str_replace('.', '_', $data['method']).'_response';
137
+        $method = str_replace('.', '_', $data['method']) . '_response';
138 138
 
139 139
         if (!isset($result['sign']) || $result[$method]['code'] != '10000') {
140 140
             throw new GatewayException(
141
-                'Get Alipay API Error:'.$result[$method]['msg'].($result[$method]['sub_code'] ?? ''),
141
+                'Get Alipay API Error:' . $result[$method]['msg'] . ($result[$method]['sub_code'] ?? ''),
142 142
                 $result,
143 143
                 $result[$method]['code']
144 144
             );
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
 
175 175
         if (Str::endsWith($privateKey, '.pem')) {
176 176
             $privateKey = openssl_pkey_get_private($privateKey);
177
-        } else {
178
-            $privateKey = "-----BEGIN RSA PRIVATE KEY-----\n".
179
-                wordwrap($privateKey, 64, "\n", true).
177
+        }else {
178
+            $privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" .
179
+                wordwrap($privateKey, 64, "\n", true) .
180 180
                 "\n-----END RSA PRIVATE KEY-----";
181 181
         }
182 182
 
@@ -212,16 +212,15 @@  discard block
 block discarded – undo
212 212
 
213 213
         if (Str::endsWith($publicKey, '.pem')) {
214 214
             $publicKey = openssl_pkey_get_public($publicKey);
215
-        } else {
216
-            $publicKey = "-----BEGIN PUBLIC KEY-----\n".
217
-                wordwrap($publicKey, 64, "\n", true).
215
+        }else {
216
+            $publicKey = "-----BEGIN PUBLIC KEY-----\n" .
217
+                wordwrap($publicKey, 64, "\n", true) .
218 218
                 "\n-----END PUBLIC KEY-----";
219 219
         }
220 220
 
221 221
         $sign = $sign ?? $data['sign'];
222 222
 
223
-        $toVerify = $sync ? mb_convert_encoding(json_encode($data, JSON_UNESCAPED_UNICODE), 'gb2312', 'utf-8') :
224
-                            self::getSignContent($data, true);
223
+        $toVerify = $sync ? mb_convert_encoding(json_encode($data, JSON_UNESCAPED_UNICODE), 'gb2312', 'utf-8') : self::getSignContent($data, true);
225 224
 
226 225
         return openssl_verify($toVerify, base64_decode($sign), $publicKey, OPENSSL_ALGO_SHA256) === 1;
227 226
     }
@@ -245,10 +244,10 @@  discard block
 block discarded – undo
245 244
         $stringToBeSigned = '';
246 245
         foreach ($data as $k => $v) {
247 246
             if ($verify && $k != 'sign' && $k != 'sign_type') {
248
-                $stringToBeSigned .= $k.'='.$v.'&';
247
+                $stringToBeSigned .= $k . '=' . $v . '&';
249 248
             }
250 249
             if (!$verify && $v !== '' && !is_null($v) && $k != 'sign' && '@' != substr($v, 0, 1)) {
251
-                $stringToBeSigned .= $k.'='.$v.'&';
250
+                $stringToBeSigned .= $k . '=' . $v . '&';
252 251
             }
253 252
         }
254 253
 
Please login to merge, or discard this patch.
src/Gateways/Wechat/Support.php 1 patch
Spacing   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 
167 167
         if (!isset($result['return_code']) || $result['return_code'] != 'SUCCESS' || $result['result_code'] != 'SUCCESS') {
168 168
             throw new GatewayException(
169
-                'Get Wechat API Error:'.($result['return_msg'] ?? $result['retmsg']).($result['err_code_des'] ?? ''),
169
+                'Get Wechat API Error:' . ($result['return_msg'] ?? $result['retmsg']) . ($result['err_code_des'] ?? ''),
170 170
                 $result,
171 171
                 20000
172 172
             );
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
         $payload['appid'] = self::$instance->getConfig($type, '');
206 206
 
207 207
         if (self::$instance->getConfig('mode', Wechat::MODE_NORMAL) === Wechat::MODE_SERVICE) {
208
-            $payload['sub_appid'] = self::$instance->getConfig('sub_'.$type, '');
208
+            $payload['sub_appid'] = self::$instance->getConfig('sub_' . $type, '');
209 209
         }
210 210
 
211 211
         unset($payload['trade_type'], $payload['type']);
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 
240 240
         ksort($data);
241 241
 
242
-        $string = md5(self::getSignContent($data).'&key='.$key);
242
+        $string = md5(self::getSignContent($data) . '&key=' . $key);
243 243
 
244 244
         Log::debug('Wechat Generate Sign Before UPPER', [$data, $string]);
245 245
 
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
         $buff = '';
261 261
 
262 262
         foreach ($data as $k => $v) {
263
-            $buff .= ($k != 'sign' && $v != '' && !is_array($v)) ? $k.'='.$v.'&' : '';
263
+            $buff .= ($k != 'sign' && $v != '' && !is_array($v)) ? $k . '=' . $v . '&' : '';
264 264
         }
265 265
 
266 266
         Log::debug('Wechat Generate Sign Content Before Trim', [$data, $buff]);
@@ -306,8 +306,7 @@  discard block
 block discarded – undo
306 306
 
307 307
         $xml = '<xml>';
308 308
         foreach ($data as $key => $val) {
309
-            $xml .= is_numeric($val) ? '<'.$key.'>'.$val.'</'.$key.'>' :
310
-                                       '<'.$key.'><![CDATA['.$val.']]></'.$key.'>';
309
+            $xml .= is_numeric($val) ? '<' . $key . '>' . $val . '</' . $key . '>' : '<' . $key . '><![CDATA[' . $val . ']]></' . $key . '>';
311 310
         }
312 311
         $xml .= '</xml>';
313 312
 
@@ -378,7 +377,7 @@  discard block
 block discarded – undo
378 377
                 $type = 'appid';
379 378
                 break;
380 379
             default:
381
-                $type = $type.'_id';
380
+                $type = $type . '_id';
382 381
         }
383 382
 
384 383
         return $type;
Please login to merge, or discard this patch.