Completed
Push — master ( d5125b...6b1430 )
by Vuong
02:40
created

BankWidget::getBankProvider()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3.0987

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 7
cts 9
cp 0.7778
rs 9.6666
c 0
b 0
f 0
cc 3
nc 3
nop 0
crap 3.0987
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;
9
10
use yii\helpers\Html;
11
use yii\widgets\InputWidget;
12
13
/**
14
 * Lớp BaseWidget hổ trợ render input danh sách ngân hàng cho user chọn (dropdown list).
15
 *
16
 * @author Vuong Minh <[email protected]>
17
 * @since 1.0.3
18
 */
19
class BankWidget extends InputWidget
20
{
21
22
    use GatewayBankProviderTrait;
23
24
    /**
25
     * @inheritdoc
26
     */
27 2
    public function run()
28
    {
29 2
        if ($this->hasModel()) {
30
31
            return Html::activeDropDownList($this->model, $this->attribute, $this->bankProvider->banks(), $this->options);
32
        } else {
33
34 2
            return Html::dropDownList($this->name, $this->value, $this->bankProvider->banks(), $this->options);
35
        }
36
    }
37
38
}
39