RadioGroup   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 92.31%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 34
ccs 12
cts 13
cp 0.9231
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toggleCurrent() 0 14 3
A getCheckedValues() 0 8 2
1
<?php
2
3
namespace League\CLImate\TerminalObject\Dynamic\Checkbox;
4
5
class RadioGroup extends CheckboxGroup
6
{
7
    /**
8
     * Toggle the currently selected option, uncheck all of the others
9
     */
10 4
    public function toggleCurrent()
11
    {
12 4
        list($checkbox, $checkbox_key) = $this->getCurrent();
13
14 4
        $checkbox->setChecked(!$checkbox->isChecked());
15
16 4
        foreach ($this->checkboxes as $key => $checkbox) {
17 4
            if ($key == $checkbox_key) {
18 4
                continue;
19
            }
20
21 4
            $checkbox->setChecked(false);
22 4
        }
23 4
    }
24
25
    /**
26
     * Get the checked option
27
     *
28
     * @return string|bool|int
29
     */
30 4
    public function getCheckedValues()
31
    {
32 4
        if ($checked = $this->getChecked()) {
33 4
            return reset($checked)->getValue();
34
        }
35
36
        return null;
37
    }
38
}
39