Test Failed
Push — master ( 194522...eda1b6 )
by Mikael
01:43
created

FormElementCheckbox::__construct()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 10
nc 4
nop 2
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Anax\HTMLForm;
4
5
/**
6
 * Form element
7
 */
8
class FormElementCheckbox extends FormElement
9
{
10
11
    /**
12
     * Constructor
13
     *
14
     * @param string $name       of the element.
15
     * @param array  $attributes to set to the element. Default is an empty array.
16
     */
17
    public function __construct($name, $attributes = [])
18
    {
19
        parent::__construct($name, $attributes);
20
21
        $this['type'] = 'checkbox';
22
        
23
        $this['checked'] = isset($attributes['checked'])
24
            ? $attributes['checked']
25
            : false;
26
            
27
        $this['value'] = isset($attributes['value'])
28
            ? $attributes['value']
29
            : $name;
30
            
31
        $this->UseNameAsDefaultLabel(null);
32
    }
33
}
34