Passed
Push — master ( acf3f9...98cfe3 )
by Derek Stephen
03:04
created

FormRenderer::renderFieldLabel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
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
}