Completed
Push — master ( bb7932...80c2ce )
by Vuong
01:37
created

ResponseData::getIsOk()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
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 2
    public function getIsOk(): bool
30
    {
31 2
        return !isset($this['error_code'], $this['error']);
32
    }
33
34
    /**
35
     * 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
     */
39
    public function getErrorMessage(): ?string
40
    {
41
        if (isset($this['error'])) {
42
            return $this['error'];
43
        } else {
44
            return null;
45
        }
46
    }
47
}
48