| Total Complexity | 5 |
| Total Lines | 59 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 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 | |||
| 35 | |||
| 36 | /** |
||
| 37 | * Get the value of the form element. |
||
| 38 | * |
||
| 39 | * @return array the checked values of the form element. |
||
| 40 | */ |
||
| 41 | public function value() |
||
| 42 | { |
||
| 43 | return $this['checked']; |
||
| 44 | } |
||
| 45 | |||
| 46 | |||
| 47 | |||
| 48 | /** |
||
| 49 | * Get HTML code for a element. |
||
| 50 | * |
||
| 51 | * @return string HTML code for the element. |
||
| 52 | * |
||
| 53 | * @SuppressWarnings(PHPMD.UnusedLocalVariable) |
||
| 54 | */ |
||
| 55 | public function getHTML() |
||
| 67 | EOD; |
||
| 68 | } |
||
| 69 | } |
||
| 70 |