Completed
Push — master ( 8431a9...0bccd4 )
by Gabriel
04:28
created

Nip_Form_Renderer_Paragraph::renderRows()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 9
ccs 0
cts 6
cp 0
rs 10
cc 2
nc 2
nop 0
crap 6
1
<?php
2
3
use Nip\Form\Renderer\AbstractRenderer;
4
5
class Nip_Form_Renderer_Paragraph extends AbstractRenderer
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
6
{
7
    public function renderElements()
8
    {
9
        $return = '';
10
11
        $renderRows = $this->renderRows();
12
        if ($renderRows) {
13
            $return .= $renderRows;
14
        }
15
16
        return $return;
17
    }
18
19
    public function renderRows()
20
    {
21
        $elements = $this->getElements();
22
        $return = '';
23
        foreach ($elements as $element) {
24
            $return .= $this->renderRow($element);
25
        }
26
27
        return $return;
28
    }
29
30
    public function renderRow($element)
31
    {
32
        $return = '';
33
        if (!$element->isRendered()) {
34
            $return .= '<p class="row row-'.$element->getUniqueId().($element->isError() ? ' error' : '').'">';
35
36
            $return .= $this->renderLabel($element);
37
38
            $class = "value ".($element->getType() == 'input' ? 'input' : '');
39
            $return .= '<span class="'.$class.'">';
40
            $return .= $element->renderElement();
41
            $return .= '</span>';
42
43
            $return .= $element->renderErrors();
44
45
            $return .= '</p>';
46
        }
47
48
        return $return;
49
    }
50
}
51