Completed
Push — master ( 73de08...39d3cf )
by Gabor
03:53
created

InputElement   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 62
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A setType() 0 8 2
A getType() 0 4 1
1
<?php
2
/**
3
 * WebHemi.
4
 *
5
 * PHP version 5.6
6
 *
7
 * @copyright 2012 - 2016 Gixx-web (http://www.gixx-web.com)
8
 * @license   https://opensource.org/licenses/MIT The MIT License (MIT)
9
 *
10
 * @link      http://www.gixx-web.com
11
 */
12
namespace WebHemi\Form\Element\Web;
13
14
/**
15
 * Class InputElement.
16
 */
17
class InputElement extends AbstractElement
18
{
19
    /** @var string */
20
    private $type = 'text';
21
    /** @var array */
22
    private $availableInputTypes = [
23
        'color',
24
        'date',
25
        'datetime',
26
        'datetime-local',
27
        'email',
28
        'image',
29
        'month',
30
        'number',
31
        'range',
32
        'search',
33
        'tel',
34
        'text',
35
        'time',
36
        'url',
37
        'week',
38
    ];
39
40
    /**
41
     * SelectElement constructor.
42
     *
43
     * @param string $name
44
     * @param string $label
45
     * @param mixed  $value
46
     */
47
    public function __construct($name = '', $label = '', $value = null)
48
    {
49
        parent::__construct($name, $label, $value);
50
51
        $this->setTabIndex();
52
    }
53
54
    /**
55
     * Sets input element type.
56
     *
57
     * @param string $type
58
     * @return InputElement
59
     */
60
    public function setType($type = 'text')
61
    {
62
        if (in_array($type, $this->availableInputTypes)) {
63
            $this->type = $type;
64
        }
65
66
        return $this;
67
    }
68
69
    /**
70
     * Returns the element type.
71
     *
72
     * @return string
73
     */
74
    public function getType()
75
    {
76
        return $this->type;
77
    }
78
}
79