FormRenderer::renderFieldBlock()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 18
ccs 10
cts 10
cp 1
rs 9.9666
cc 2
nc 2
nop 0
crap 2
1
<?php
2
/**
3
 * User: delboy1978uk
4
 * Date: 29/11/2016
5
 * Time: 19:44
6
 */
7
8
namespace Del\Form\Renderer;
9
10
use Del\Form\Field\CheckBox;
11
use Del\Form\Field\Radio;
12
use DOMElement;
13
use DOMText;
14
15
class FormRenderer extends AbstractFormRenderer implements FormRendererInterface
16
{
17
    /**
18
     * @return DOMElement
19
     */
20 31
    public function renderFieldLabel()
21
    {
22 31
        $label = $this->createLabelElement();
23 31
        $text = new DOMText($this->field->getLabel() ?? '');
24 31
        $label->appendChild($text);
25 31
        return $label;
26
    }
27
28
    /**
29
     * @return DomElement
30
     */
31 24
    public function renderFieldBlock()
32
    {
33
        // Set form group div properties
34 24
        $formGroup = $this->block;
35 24
        $class = $formGroup->getAttribute('class').'form-group';
36 24
        $formGroup->setAttribute('class', $class);
37 24
        $formGroup->setAttribute('id', $this->field->getName().'-form-group');
38
39 24
        $formGroup->appendChild($this->label);
40
41 24
        $formGroup->appendChild($this->element);
42
43 24
        if (!is_null($this->errors)) {
44 3
            $formGroup->appendChild($this->errors);
45
        }
46
47
        // Field rendered! Pass it back!
48 24
        return $formGroup;
49
    }
50
51
}
52