Nip_Form_Element_Radio::setChecked()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 9
ccs 3
cts 4
cp 0.75
rs 10
cc 2
nc 2
nop 1
crap 2.0625
1
<?php
2
3
class Nip_Form_Element_Radio extends Nip_Form_Element_Input_Abstract
4
{
5
    protected $_type = 'radio';
6 3
7
    public function init()
8 3
    {
9 3
        parent::init();
10 3
        $this->setAttrib('type', 'radio');
11
    }
12
13
    public function isChecked()
14
    {
15
        return $this->getAttrib('checked') == 'checked';
16
    }
17
18 2
19
    public function setChecked($checked)
20 2
    {
21 2
        if ($checked === true) {
22
            $this->setAttrib('checked', 'checked');
23
        } else {
24
            $this->delAttrib('checked');
25
        }
26 2
27
        return $this;
28
    }
29
}
30