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

Nip_Form_Element_Time   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 10
c 1
b 0
f 1
dl 0
loc 22
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 14 3
A init() 0 4 1
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