Completed
Push — master ( 4f7c7c...fdaf8f )
by Vuong
02:10
created

VerifiedData   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 35.48 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 11
loc 31
ccs 2
cts 4
cp 0.5
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 11 11 1
A getDataSignAttributes() 0 7 1

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
 * @link https://github.com/yiiviet/yii2-payment
4
 * @copyright Copyright (c) 2017 Yii Viet
5
 * @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
6
 */
7
8
namespace yiiviet\payment\momo;
9
10
use yiiviet\payment\VerifiedData as BaseVerifiedData;
11
12
/**
13
 * Lớp VerifiedData
14
 *
15
 * @method PaymentClient getClient() đối tượng client đã dùng để thực thi request.
16
 *
17
 * @property PaymentClient $client đối tượng client đã dùng để thực thi request.
18
 * @property string $partnerCode của client sử dụng khi tạo request purchase.
19
 * @property string $accessKey của client sử dụng khi tạo request purchase.
20
 * @property mixed $requestId mã unique request id khi tạo request purchase
21
 * @property double $amount số tiền của đơn hàng.
22
 * @property string $orderId mã đơn hàng tại hệ thống.
23
 * @property string $orderType có giá trị cố định là `momo_wallet`.
24
 * @property string $transId mã giao dịch tại MOMO.
25
 * @property string $message thống báo (eng).
26
 * @property string $localMessage thống báo (vi).
27
 * @property string $responseTime thời gian phản hồi.
28
 * @property int $errorCode mã báo lỗi.
29
 * @property string $payType hình thức thanh toán (web hoặc qr).
30
 * @property mixed $extraData dữ liệu kèm theo khi tạo request purchase.
31
 *
32
 * @author Vuong Minh <[email protected]>
33
 * @since 1.0.3
34
 */
35
class VerifiedData extends BaseVerifiedData
36
{
37
38
    use SignatureValidatorTrait;
39
40
    /**
41
     * @inheritdoc
42
     */
43 2 View Code Duplication
    public function rules()
0 ignored issues
show
Duplication introduced by
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...
44
    {
45
        return [
46 2
            [['signature'], 'required', 'on' => [
47
                PaymentGateway::VRC_PURCHASE_SUCCESS, PaymentGateway::VRC_IPN
48
            ]],
49
            [['signature'], 'signatureValidator', 'message' => '{attribute} is not valid!', 'on' => [
50
                PaymentGateway::VRC_PURCHASE_SUCCESS, PaymentGateway::VRC_IPN
51
            ]]
52
        ];
53
    }
54
55
    /**
56
     * @inheritdoc
57
     */
58
    protected function getDataSignAttributes(): array
59
    {
60
        return [
61
            'partnerCode', 'accessKey', 'requestId', 'amount', 'orderId', 'orderInfo', 'orderType',
62
            'transId', 'message', 'localMessage', 'responseTime', 'errorCode', 'payType', 'extraData'
63
        ];
64
    }
65
}
66