Nip_Form_Renderer_Elements_Radio   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 14
c 1
b 0
f 0
dl 0
loc 34
ccs 14
cts 16
cp 0.875
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getelementattribs() 0 6 1
A renderInput() 0 3 1
A generateElement() 0 13 2
1
<?php
2
3
class Nip_Form_Renderer_Elements_Radio extends Nip_Form_Renderer_Elements_Input_Abstract
4
{
5
    /**
6
     * @return string
7
     */
8 3
    public function generateElement()
9
    {
10 3
        $this->getElement()->addClass('form-check-input');
11
12 3
        $class = get_class($this->getRenderer()) == Nip_Form_Renderer_Bootstrap::class ? 'radio' : 'form-check';
13 3
        $return = '<div class="' . $class . '">';
14 3
        $return .= '<label class="form-check-label">';
15 3
        $return .= parent::generateElement();
16 3
        $return .= $this->getElement()->getLabel();
17 3
        $return .= '</label>';
18 3
        $return .= '</div>';
19
20 3
        return $return;
21
    }
22
23
    /**
24
     * @return string
25
     */
26
    public function renderInput()
27
    {
28
        return parent::generateElement();
29
    }
30
31 3
    public function getelementattribs()
32
    {
33 3
        $attribs = parent::getelementattribs();
34 3
        $attribs[] = 'checked';
35
36 3
        return $attribs;
37
    }
38
}
39