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

CheckboxElement   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 43
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 4 1
A setValue() 0 10 4
A getValue() 0 8 2
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 RadioElement.
16
 */
17
class CheckboxElement extends RadioElement
18
{
19
    /**
20
     * Returns the element type.
21
     *
22
     * @return string
23
     */
24
    public function getType()
25
    {
26
        return 'checkbox';
27
    }
28
29
    /**
30
     * Sets element value.
31
     *
32
     * @param mixed $value
33
     * @return RadioElement
34
     */
35
    public function setValue($value)
36
    {
37
        if (empty($this->options) && is_numeric($value)) {
38
            $this->value = $value ? 1 : 0;
39
        } else {
40
            parent::setValue($value);
41
        }
42
43
        return $this;
44
    }
45
46
    /**
47
     * Returns element value.
48
     *
49
     * @return mixed
50
     */
51
    public function getValue()
52
    {
53
        if (empty($this->options)) {
54
            return $this->value;
55
        }
56
57
        return parent::getValue();
58
    }
59
}
60