Completed
Push — master ( 552a80...bb7932 )
by Vuong
01:49
created

ResponseData   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 25
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getIsOk() 0 4 1
A getErrorMessage() 0 8 2
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\baokim;
9
10
use Yii;
11
12
use vxm\gatewayclients\ResponseData as BaseResponseData;
13
14
/**
15
 * Lớp ResponseData cung cấp dữ liệu nhận được từ Bảo Kim khi tạo [[request()]] ở [[PaymentGateway]].
16
 *
17
 * @property PaymentClient $merchant
18
 * @property null|string $errorMessage
19
 *
20
 * @author Vuong Minh <[email protected]>
21
 * @since 1.0
22
 */
23
class ResponseData extends BaseResponseData
24
{
25
26
    /**
27
     * @inheritdoc
28
     */
29 5
    public function getIsOk(): bool
30
    {
31 5
        return !isset($this['error_code'], $this['error']);
32 5
    }
33
34 5
    /**
35 5
     * Phương thức hổ trợ lấy câu báo lỗi nhận từ Bảo Kim.
36
     *
37
     * @return null|string Trả về NULL nếu như dữ liệu Bảo Kim gửi về không tồn tại `error` và ngược lại.
38 5
     */
39 5
    public function getErrorMessage(): ?string
40
    {
41
        if (isset($this['error'])) {
42
            return $this['error'];
43
        } else {
44 4
            return null;
45
        }
46 4
    }
47
}
48