FormRenderer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
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 27
ccs 15
cts 15
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A renderFieldLabel() 0 6 1
A renderFieldBlock() 0 17 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Del\Form\Renderer;
6
7
use DOMElement;
8
use DOMText;
9
10
class FormRenderer extends AbstractFormRenderer
11
{
12 33
    public function renderFieldLabel(): DOMElement
13
    {
14 33
        $label = $this->createLabelElement();
15 33
        $text = new DOMText($this->field->getLabel() ?? '');
16 33
        $label->appendChild($text);
17 33
        return $label;
18
    }
19
20 25
    public function renderFieldBlock(): DomElement
21
    {
22
        // Set form group div properties
23 25
        $formGroup = $this->block;
24 25
        $class = $formGroup->getAttribute('class').'form-group';
25 25
        $formGroup->setAttribute('class', $class);
26 25
        $formGroup->setAttribute('id', $this->field->getName().'-form-group');
27
28 25
        $formGroup->appendChild($this->label);
29
30 25
        $formGroup->appendChild($this->element);
31
32 25
        if (!is_null($this->errors)) {
33 3
            $formGroup->appendChild($this->errors);
34
        }
35
36 25
        return $formGroup;
37
    }
38
}
39