RadioSelect   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 29
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getClasses() 0 6 1
A getHTML() 0 9 3
1
<?php
2
3
namespace fieldwork\components;
4
5
class RadioSelect extends Field
6
{
7
8
    private $options;
9
10
    public function __construct ($slug, $label, array $options = array(), $value = '', $storeValueLocally = 0)
11
    {
12
        parent::__construct($slug, $label, $value, $storeValueLocally);
13
        $this->options = $options;
14
    }
15
16
    public function getClasses ()
17
    {
18
        return array_merge(
19
            parent::getClasses(), array('radios')
20
        );
21
    }
22
23
    public function getHTML ($showLabel = true)
24
    {
25
        $r = "<div id=\"". $this->getId() . "\" class=\"radios-group\"><div class=\"radios-label\">" . $this->getLabel() . "</div>";
26
        foreach ($this->options as $v => $l) {
27
            $r .= "<div class=\"radio-option\"><input type=\"radio\" id=\"" . $this->getGlobalSlug() . "-" . $v . "\" name=\"" . $this->getName() . "\" value=\"" . $v . "\" " . ($v == $this->getValue() ? "checked" : "") . "><label for=\"" . $this->getGlobalSlug() . "-" . $v . "\">" . $l . "</label></div>";
28
        }
29
        $r .= "</div>";
30
        return $r;
31
    }
32
33
}