TransferGateway   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 23.68 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 9
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A pay() 9 9 1
A find() 0 7 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Yansongda\Pay\Gateways\Alipay;
4
5
use Yansongda\Pay\Contracts\GatewayInterface;
6
use Yansongda\Pay\Events;
7
use Yansongda\Pay\Exceptions\GatewayException;
8
use Yansongda\Pay\Exceptions\InvalidConfigException;
9
use Yansongda\Pay\Exceptions\InvalidSignException;
10
use Yansongda\Supports\Collection;
11
12
class TransferGateway implements GatewayInterface
13
{
14
    /**
15
     * Pay an order.
16
     *
17
     * @author yansongda <[email protected]>
18
     *
19
     * @param string $endpoint
20
     *
21
     * @throws GatewayException
22
     * @throws InvalidConfigException
23
     * @throws InvalidSignException
24
     */
25 View Code Duplication
    public function pay($endpoint, array $payload): Collection
0 ignored issues
show
Duplication introduced by yansongda
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
    {
27
        $payload['method'] = 'alipay.fund.trans.uni.transfer';
28
        $payload['sign'] = Support::generateSign($payload);
29
30
        Events::dispatch(new Events\PayStarted('Alipay', 'Transfer', $endpoint, $payload));
31
32
        return Support::requestApi($payload);
33
    }
34
35
    /**
36
     * Find.
37
     *
38
     * @author yansongda <[email protected]>
39
     *
40
     * @param $order
41
     */
42
    public function find($order): array
43
    {
44
        return [
45
            'method' => 'alipay.fund.trans.order.query',
46
            'biz_content' => json_encode(is_array($order) ? $order : ['out_biz_no' => $order]),
47
        ];
48
    }
49
}
50