Nip_Form_Renderer_Elements_Input_Group   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 76.47%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 15
c 1
b 0
f 0
dl 0
loc 50
ccs 13
cts 17
cp 0.7647
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setSeparator() 0 5 1
A getSeparator() 0 3 1
A generateElement() 0 11 2
A renderChildElement() 0 7 2
1
<?php
2
3
use Nip_Form_Element_Checkbox as Checkbox;
4
use Nip_Form_Element_Input_Abstract as AbstractInput;
5
6
/**
7
 * Class Nip_Form_Renderer_Elements_Input_Group
8
 * @method Nip_Form_Element_Input_Group getElement()
9
 */
10
abstract class Nip_Form_Renderer_Elements_Input_Group extends Nip_Form_Renderer_Elements_Input_Abstract
11
{
12
    protected $_separator = '<br />';
13
14
    /** @noinspection PhpMissingParentCallCommonInspection
15
     * @return string
16
     */
17 5
    public function generateElement()
18
    {
19 5
        $elements = $this->getElement()->getElements();
20 5
        $returnElements = [];
21 5
        $return = '';
22 5
        foreach ($elements as $element) {
23 3
            $returnElements[] = $this->renderChildElement($element);
24
        }
25 5
        $return .= implode($this->getSeparator(), $returnElements);
26
27 5
        return $return;
28
    }
29
30
    /**
31
     * @param AbstractInput|Checkbox $element
32
     * @return mixed
33
     */
34 3
    public function renderChildElement($element)
35
    {
36 3
        if ($element->getValue() == $this->getElement()->getValue()) {
37
            $element->setChecked(true);
0 ignored issues
show
Bug introduced by
The method setChecked() does not exist on Nip_Form_Element_Input_Abstract. It seems like you code against a sub-type of Nip_Form_Element_Input_Abstract such as Nip_Form_Element_Radio or Nip_Form_Element_Checkbox. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
            $element->/** @scrutinizer ignore-call */ 
38
                      setChecked(true);
Loading history...
38
        }
39
40 3
        return $element->render();
41
    }
42
43
    /**
44
     * @return string
45
     */
46 5
    public function getSeparator()
47
    {
48 5
        return $this->_separator;
49
    }
50
51
    /**
52
     * @param $separator
53
     * @return $this
54
     */
55
    public function setSeparator($separator)
56
    {
57
        $this->_separator = $separator;
58
59
        return $this;
60
    }
61
}
62