Time   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 2
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A inputAttributes() 0 7 1
A renderScript() 0 10 2
1
<?php
2
namespace Rocket\UI\Forms\Fields;
3
4
/**
5
 * Manage date fields
6
 */
7
8
/**
9
 * Creates a date field with Form_element
10
 *
11
 * @author Stéphane Goetz
12
 */
13
class Time extends Field
14
{
15
    /**
16
     * Adds some specific attributes to be able to use the date picker automatically
17
     */
18
    protected function inputAttributes()
19
    {
20
        parent::inputAttributes();
21
22
        $this->input_attributes['type'] = 'text';
23
        $this->input_attributes['class'][] = 'time';
24
    }
25
26
    /**
27
     * Adds the script logic to the picker
28
     */
29
    protected function renderScript()
30
    {
31
        $options = ['format' => 'H:i'];
32
33
        if (array_key_exists('options', $this->params)) {
34
            $options = array_merge($this->params['options'], $options);
35
        }
36
37
        $this->getJS()->ready('$( "#' . $this->id . '").pickatime(' . json_encode($options) . ');');
38
    }
39
}
40