FormRenderer::renderFieldLabel()   A
last analyzed

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
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