Completed
Pull Request — master (#253)
by
unknown
02:30
created
src/Exceptions/InvalidArgumentException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,6 +14,6 @@
 block discarded – undo
14 14
      */
15 15
     public function __construct($message, $raw = [])
16 16
     {
17
-        parent::__construct('INVALID_ARGUMENT: '.$message, $raw, self::INVALID_ARGUMENT);
17
+        parent::__construct('INVALID_ARGUMENT: ' . $message, $raw, self::INVALID_ARGUMENT);
18 18
     }
19 19
 }
Please login to merge, or discard this patch.
src/Gateways/Wechat/Support.php 1 patch
Spacing   +9 added lines, -10 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
      */
159 159
     public static function requestApi($endpoint, $data, $cert = false): Collection
160 160
     {
161
-        Events::dispatch(Events::API_REQUESTING, new Events\ApiRequesting('Wechat', '', self::$instance->getBaseUri().$endpoint, $data));
161
+        Events::dispatch(Events::API_REQUESTING, new Events\ApiRequesting('Wechat', '', self::$instance->getBaseUri() . $endpoint, $data));
162 162
 
163 163
         $result = self::$instance->post(
164 164
             $endpoint,
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
         );
171 171
         $result = is_array($result) ? $result : self::fromXml($result);
172 172
 
173
-        Events::dispatch(Events::API_REQUESTED, new Events\ApiRequested('Wechat', '', self::$instance->getBaseUri().$endpoint, $result));
173
+        Events::dispatch(Events::API_REQUESTED, new Events\ApiRequested('Wechat', '', self::$instance->getBaseUri() . $endpoint, $result));
174 174
 
175 175
         return self::processingApiResult($endpoint, $result);
176 176
     }
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         $payload['appid'] = self::$instance->getConfig($type, '');
200 200
 
201 201
         if (self::$instance->getConfig('mode', Wechat::MODE_NORMAL) === Wechat::MODE_SERVICE) {
202
-            $payload['sub_appid'] = self::$instance->getConfig('sub_'.$type, '');
202
+            $payload['sub_appid'] = self::$instance->getConfig('sub_' . $type, '');
203 203
         }
204 204
 
205 205
         unset($payload['trade_type'], $payload['type']);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
         ksort($data);
235 235
 
236
-        $string = md5(self::getSignContent($data).'&key='.$key);
236
+        $string = md5(self::getSignContent($data) . '&key=' . $key);
237 237
 
238 238
         Log::debug('Wechat Generate Sign Before UPPER', [$data, $string]);
239 239
 
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
         $buff = '';
255 255
 
256 256
         foreach ($data as $k => $v) {
257
-            $buff .= ($k != 'sign' && $v != '' && !is_array($v)) ? $k.'='.$v.'&' : '';
257
+            $buff .= ($k != 'sign' && $v != '' && !is_array($v)) ? $k . '=' . $v . '&' : '';
258 258
         }
259 259
 
260 260
         Log::debug('Wechat Generate Sign Content Before Trim', [$data, $buff]);
@@ -300,8 +300,7 @@  discard block
 block discarded – undo
300 300
 
301 301
         $xml = '<xml>';
302 302
         foreach ($data as $key => $val) {
303
-            $xml .= is_numeric($val) ? '<'.$key.'>'.$val.'</'.$key.'>' :
304
-                                       '<'.$key.'><![CDATA['.$val.']]></'.$key.'>';
303
+            $xml .= is_numeric($val) ? '<' . $key . '>' . $val . '</' . $key . '>' : '<' . $key . '><![CDATA[' . $val . ']]></' . $key . '>';
305 304
         }
306 305
         $xml .= '</xml>';
307 306
 
@@ -372,7 +371,7 @@  discard block
 block discarded – undo
372 371
                 $type = 'appid';
373 372
                 break;
374 373
             default:
375
-                $type = $type.'_id';
374
+                $type = $type . '_id';
376 375
         }
377 376
 
378 377
         return $type;
@@ -408,14 +407,14 @@  discard block
 block discarded – undo
408 407
     {
409 408
         if (!isset($result['return_code']) || $result['return_code'] != 'SUCCESS') {
410 409
             throw new GatewayException(
411
-                'Get Wechat API Error:'.($result['return_msg'] ?? $result['retmsg'] ?? ''),
410
+                'Get Wechat API Error:' . ($result['return_msg'] ?? $result['retmsg'] ?? ''),
412 411
                 $result
413 412
             );
414 413
         }
415 414
 
416 415
         if (isset($result['result_code']) && $result['result_code'] != 'SUCCESS') {
417 416
             throw new BusinessException(
418
-                'Wechat Business Error: '.$result['err_code'].' - '.$result['err_code_des'],
417
+                'Wechat Business Error: ' . $result['err_code'] . ' - ' . $result['err_code_des'],
419 418
                 $result
420 419
             );
421 420
         }
Please login to merge, or discard this patch.
src/Exceptions/GatewayException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,6 +15,6 @@
 block discarded – undo
15 15
      */
16 16
     public function __construct($message, $raw = [], $code = self::ERROR_GATEWAY)
17 17
     {
18
-        parent::__construct('ERROR_GATEWAY: '.$message, $raw, $code);
18
+        parent::__construct('ERROR_GATEWAY: ' . $message, $raw, $code);
19 19
     }
20 20
 }
Please login to merge, or discard this patch.
src/Gateways/Alipay.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
         $this->payload['biz_content'] = json_encode($params);
128 128
 
129
-        $gateway = get_class($this).'\\'.Str::studly($gateway).'Gateway';
129
+        $gateway = get_class($this) . '\\' . Str::studly($gateway) . 'Gateway';
130 130
 
131 131
         if (class_exists($gateway)) {
132 132
             return $this->makePay($gateway);
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
             $type = 'wap';
204 204
         }
205 205
 
206
-        $gateway = get_class($this).'\\'.Str::studly($type).'Gateway';
206
+        $gateway = get_class($this) . '\\' . Str::studly($type) . 'Gateway';
207 207
 
208 208
         if (!class_exists($gateway) || !is_callable([new $gateway(), 'find'])) {
209 209
             throw new GatewayException("{$gateway} Done Not Exist Or Done Not Has FIND Method");
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
         $app = new $gateway();
363 363
 
364 364
         if ($app instanceof GatewayInterface) {
365
-            return $app->pay($this->gateway, array_filter($this->payload, function ($value) {
365
+            return $app->pay($this->gateway, array_filter($this->payload, function($value) {
366 366
                 return $value !== '' && !is_null($value);
367 367
             }));
368 368
         }
Please login to merge, or discard this patch.
src/Gateways/Alipay/WebGateway.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -71,13 +71,13 @@
 block discarded – undo
71 71
     protected function buildPayHtml($endpoint, $payload, $method = 'POST'): Response
72 72
     {
73 73
         if (strtoupper($method) === 'GET') {
74
-            return RedirectResponse::create($endpoint.'?'.http_build_query($payload));
74
+            return RedirectResponse::create($endpoint . '?' . http_build_query($payload));
75 75
         }
76 76
 
77
-        $sHtml = "<form id='alipay_submit' name='alipay_submit' action='".$endpoint."' method='".$method."'>";
77
+        $sHtml = "<form id='alipay_submit' name='alipay_submit' action='" . $endpoint . "' method='" . $method . "'>";
78 78
         foreach ($payload as $key => $val) {
79 79
             $val = str_replace("'", '&apos;', $val);
80
-            $sHtml .= "<input type='hidden' name='".$key."' value='".$val."'/>";
80
+            $sHtml .= "<input type='hidden' name='" . $key . "' value='" . $val . "'/>";
81 81
         }
82 82
         $sHtml .= "<input type='submit' value='ok' style='display:none;'></form>";
83 83
         $sHtml .= "<script>document.forms['alipay_submit'].submit();</script>";
Please login to merge, or discard this patch.
src/Gateways/Alipay/Support.php 1 patch
Spacing   +13 added lines, -14 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
 
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 
160 160
         if (Str::endsWith($privateKey, '.pem')) {
161 161
             $privateKey = openssl_pkey_get_private($privateKey);
162
-        } else {
163
-            $privateKey = "-----BEGIN RSA PRIVATE KEY-----\n".
164
-                wordwrap($privateKey, 64, "\n", true).
162
+        }else {
163
+            $privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" .
164
+                wordwrap($privateKey, 64, "\n", true) .
165 165
                 "\n-----END RSA PRIVATE KEY-----";
166 166
         }
167 167
 
@@ -201,16 +201,15 @@  discard block
 block discarded – undo
201 201
 
202 202
         if (Str::endsWith($publicKey, '.pem')) {
203 203
             $publicKey = openssl_pkey_get_public($publicKey);
204
-        } else {
205
-            $publicKey = "-----BEGIN PUBLIC KEY-----\n".
206
-                wordwrap($publicKey, 64, "\n", true).
204
+        }else {
205
+            $publicKey = "-----BEGIN PUBLIC KEY-----\n" .
206
+                wordwrap($publicKey, 64, "\n", true) .
207 207
                 "\n-----END PUBLIC KEY-----";
208 208
         }
209 209
 
210 210
         $sign = $sign ?? $data['sign'];
211 211
 
212
-        $toVerify = $sync ? mb_convert_encoding(json_encode($data, JSON_UNESCAPED_UNICODE), 'gb2312', 'utf-8') :
213
-                            self::getSignContent($data, true);
212
+        $toVerify = $sync ? mb_convert_encoding(json_encode($data, JSON_UNESCAPED_UNICODE), 'gb2312', 'utf-8') : self::getSignContent($data, true);
214 213
 
215 214
         $isVerify = openssl_verify($toVerify, base64_decode($sign), $publicKey, OPENSSL_ALGO_SHA256) === 1;
216 215
 
@@ -240,10 +239,10 @@  discard block
 block discarded – undo
240 239
         $stringToBeSigned = '';
241 240
         foreach ($data as $k => $v) {
242 241
             if ($verify && $k != 'sign' && $k != 'sign_type') {
243
-                $stringToBeSigned .= $k.'='.$v.'&';
242
+                $stringToBeSigned .= $k . '=' . $v . '&';
244 243
             }
245 244
             if (!$verify && $v !== '' && !is_null($v) && $k != 'sign' && '@' != substr($v, 0, 1)) {
246
-                $stringToBeSigned .= $k.'='.$v.'&';
245
+                $stringToBeSigned .= $k . '=' . $v . '&';
247 246
             }
248 247
         }
249 248
 
@@ -319,12 +318,12 @@  discard block
 block discarded – undo
319 318
      */
320 319
     protected static function processingApiResult($data, $result): Collection
321 320
     {
322
-        $method = str_replace('.', '_', $data['method']).'_response';
321
+        $method = str_replace('.', '_', $data['method']) . '_response';
323 322
 
324 323
         if (!isset($result['sign']) || $result[$method]['code'] != '10000') {
325 324
             throw new GatewayException(
326
-                'Get Alipay API Error:'.$result[$method]['msg'].
327
-                    (isset($result[$method]['sub_code']) ? (' - '.$result[$method]['sub_code']) : ''),
325
+                'Get Alipay API Error:' . $result[$method]['msg'] .
326
+                    (isset($result[$method]['sub_code']) ? (' - ' . $result[$method]['sub_code']) : ''),
328 327
                 $result
329 328
             );
330 329
         }
Please login to merge, or discard this patch.