Nip_Form_Renderer_List   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
eloc 28
c 1
b 0
f 0
dl 0
loc 57
ccs 0
cts 30
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setListAttrib() 0 5 1
A addClassName() 0 5 1
A renderRows() 0 22 4
A renderElements() 0 15 3
1
<?php
2
3
use Nip\Form\Renderer\AbstractRenderer;
4
5
class Nip_Form_Renderer_List extends AbstractRenderer
6
{
7
    protected $_list = [];
8
9
    public function setListAttrib($type, $value)
10
    {
11
        $this->_list[$type] = $value;
12
13
        return $this;
14
    }
15
16
    public function addClassName($name)
17
    {
18
        $this->_list['class'] .= ' ' . $name;
19
20
        return $this;
21
    }
22
23
    public function renderElements()
24
    {
25
        $return = '<ul';
26
        foreach ($this->_list as $attrib => $value) {
27
            $return .= ' ' . $attrib . '="' . $value . '"';
28
        }
29
        $return .= '>';
30
31
        $renderRows = $this->renderRows();
32
        if ($renderRows) {
33
            $return .= $renderRows;
34
        }
35
        $return .= '</ul>';
36
37
        return $return;
38
    }
39
40
    public function renderRows()
41
    {
42
        $elements = $this->getElements();
43
        $return = '';
44
        foreach ($elements as $element) {
45
            if (!$element->isRendered()) {
46
                $return .= '<li class="row">';
47
48
                $return = $this->renderLabel($element);
0 ignored issues
show
Deprecated Code introduced by
The function Nip\Form\Renderer\AbstractRenderer::renderLabel() has been deprecated: Use renderElementLabel() ( Ignorable by Annotation )

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

48
                $return = /** @scrutinizer ignore-deprecated */ $this->renderLabel($element);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
49
50
                $class = "value " . ($element->getType() == 'input' ? 'input' : '');
51
                $return .= '<span class="' . $class . '">';
52
                $return .= $element->renderElement();
53
                $return .= '</span>';
54
55
                $return .= $element->renderErrors();
56
57
                $return .= '</li>';
58
            }
59
        }
60
61
        return $return;
62
    }
63
}
64