Completed
Pull Request — master (#15)
by
unknown
02:55
created

BankWidget::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 3
cts 4
cp 0.75
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2.0625
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 nhuluc\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 Nhu Luc <[email protected]>
17
 * @since 1.0.3
18
 */
19
class BankWidget extends InputWidget
20
{
21
22
    use GatewayBankProviderTrait;
23
24
    /**
25
     * @inheritdoc
26
     */
27 3
    public function run()
28
    {
29 3
        if ($this->hasModel()) {
30
31
            return Html::activeDropDownList($this->model, $this->attribute, $this->provider->banks(), $this->options);
32
        } else {
33
34 3
            return Html::dropDownList($this->name, $this->value, $this->provider->banks(), $this->options);
35
        }
36
    }
37
38
}
39