Completed
Push — master ( bf6fd0...fe0998 )
by i
04:47
created

WapPayment   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 37.5%

Importance

Changes 0
Metric Value
dl 0
loc 26
ccs 3
cts 8
cp 0.375
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A toPay() 0 12 2
1
<?php
2
3
namespace Nilnice\Payment\Wechat;
4
5
use Nilnice\Payment\Constant;
6
7
class WapPayment extends AbstractWechat
8
{
9
    /**
10
     * To pay.
11
     *
12
     * @param string $gateway
13
     * @param array  $payload
14
     *
15
     * @throws \InvalidArgumentException
16
     * @throws \Nilnice\Payment\Exception\GatewayException
17
     * @throws \Nilnice\Payment\Exception\InvalidKeyException
18
     * @throws \Nilnice\Payment\Exception\InvalidSignException
19
     * @throws \RuntimeException
20
     */
21 3
    public function toPay(string $gateway, array $payload)
22
    {
23 3
        $payload['trade_type'] = Constant::WX_PAY_WAP_TYPE;
24 3
        $object = $this->prepare(Constant::WX_PAY_PREPARE_URI, $payload);
25
        $returnUrl = $this->config->get('return_url');
26
27
        if (null === $returnUrl) {
28
            $url = $object->url;
29
        } else {
30
            $url = $object->url . '&redirect_url=' . urlencode($returnUrl);
0 ignored issues
show
Bug introduced by
Are you sure $object->url of type Illuminate\Support\HigherOrderCollectionProxy can be used in concatenation? Consider adding a __toString()-method. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

30
            $url = /** @scrutinizer ignore-type */ $object->url . '&redirect_url=' . urlencode($returnUrl);
Loading history...
31
        }
32
        echo $url;
0 ignored issues
show
Bug introduced by
Are you sure $url of type Illuminate\Support\Highe...rCollectionProxy|string can be used in echo? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

32
        echo /** @scrutinizer ignore-type */ $url;
Loading history...
33
    }
34
}
35