Passed
Push — master ( 526326...f9ca3c )
by Gabriel
04:02 queued 11s
created

Nip_Form_Element_Time::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
class Nip_Form_Element_Time extends Nip_Form_Element_Input
4
{
5
    public function init()
6
    {
7
        parent::init();
8
        $this->setAttrib('type', 'time');
9
    }
10
11
    public function getData($data, $source = 'abstract')
12
    {
13
        if ($source != 'model') {
14
            return parent::getData($data, $source);
15
        }
16
17
        if ($data instanceof DateTime) {
18
            $this->setValue($data->format('H:i:s'));
19
            return $this;
20
        }
21
22
        $this->setValue($data);
23
24
        return $this;
25
    }
26
}
27