Completed
Push — master ( 1f5d0b...702fb6 )
by Andrii
11:05
created

AmountWithCurrency::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 15
ccs 0
cts 13
cp 0
crap 2
rs 9.4285
1
<?php
2
3
/*
4
 * HiPanel core package
5
 *
6
 * @link      https://hipanel.com/
7
 * @package   hipanel-core
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2014-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hipanel\widgets;
13
14
class AmountWithCurrency extends \yii\base\Widget
15
{
16
    const INPUT_TYPE_TEXT = 'text';
17
    const INPUT_TYPE_NUMBER = 'number';
18
19
    /**
20
     * @var
21
     */
22
    public $model;
23
24
    /**
25
     * @var
26
     */
27
    public $form;
28
29
    /**
30
     * @var
31
     */
32
    public $attribute;
33
34
    /**
35
     * @var
36
     */
37
    public $inputOptions = [];
38
39
    /**
40
     * @var
41
     */
42
    public $inputAttributeType;
43
44
    /**
45
     * @var
46
     */
47
    public $selectAttribute;
48
49
    /**
50
     * @var
51
     */
52
    public $selectAttributeValue;
53
54
    /**
55
     * @var array
56
     */
57
    public $selectAttributeOptions = [];
58
59
    public function init()
60
    {
61
        if ($this->inputAttributeType === null) {
62
            $this->inputAttributeType = self::INPUT_TYPE_TEXT;
63
        }
64
    }
65
66
    public function run()
67
    {
68
        return $this->render((new \ReflectionClass($this))->getShortName(), [
69
            'widgetId' => mt_rand(),
70
            'model' => $this->model,
71
72
            'attribute' => $this->attribute,
73
            'inputAttributeType' => $this->inputAttributeType,
74
            'inputOptions' => $this->inputOptions,
75
76
            'selectAttribute' => $this->selectAttribute,
77
            'selectAttributeOptions' => $this->selectAttributeOptions,
78
            'selectAttributeValue' => $this->selectAttributeValue,
79
        ]);
80
    }
81
}
82