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

FormRenderer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 14
c 0
b 0
f 0
dl 0
loc 34
ccs 15
cts 15
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A renderFieldLabel() 0 6 1
A renderFieldBlock() 0 18 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
}