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

FormElementCheckbox   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 3
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