Passed
Push — master ( 79d87e...9ca7ac )
by Alexey
05:33
created

DateTime::draw()   B

Complexity

Conditions 4
Paths 6

Size

Total Lines 25
Code Lines 19

Duplication

Lines 25
Ratio 100 %

Importance

Changes 0
Metric Value
cc 4
eloc 19
nc 6
nop 0
dl 25
loc 25
rs 8.5806
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Active form input date time
5
 *
6
 * @author Alexey Krupskiy <[email protected]>
7
 * @link http://inji.ru/
8
 * @copyright 2015 Alexey Krupskiy
9
 * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE
10
 */
11
12
namespace Ui\ActiveForm\Input;
13
14 View Code Duplication
class DateTime extends \Ui\ActiveForm\Input {
15
16
    public function draw() {
17
        $inputName = $this->colName();
18
        $inputLabel = $this->colLabel();
19
20
        $inputOptions = $this->options;
21
        if (!empty($inputOptions['minDate'])) {
22
            if (strpos($inputOptions['minDate'], 'col:') === 0) {
23
                $colName = substr($inputOptions['minDate'], 4);
24
                $inputOptions['minDate'] = $this->activeForm->model->{$colName};
25
            }
26
        }
27
        $inputOptions['value'] = $this->value();
28
        $inputOptions['disabled'] = $this->readOnly();
29
30
        $preset = $this->preset();
31
        if ($preset !== null) {
32
            $inputOptions['disabled'] = true;
33
            $this->form->input('hidden', $inputName, '', $inputOptions);
34
            return true;
35
        }
36
        $classPath = explode('\\', get_called_class());
37
        $inputType = lcfirst(array_pop($classPath));
38
        $this->form->input($inputType, $inputName, $inputLabel, $inputOptions);
39
        return true;
40
    }
41
}