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

ResponseData::ensureAttributes()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 1
crap 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