Completed
Push — master ( 077dd8...ca59d5 )
by Derek Stephen
01:55
created

FormRenderer::getId()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
cc 2
eloc 2
nc 2
nop 1
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 7 View Code Duplication
    public function renderFieldLabel()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
    {
22 7
        $label = $this->createLabelElement();
23 7
        $text = new DOMText($this->field->getLabel());
24 7
        $label->appendChild($text);
25 7
        return $label;
26
    }
27
28
    /**
29
     * @return DOMElement
30
     */
31 6
    public function renderFieldBlock()
32
    {
33
        // Set form group div properties
34 6
        $formGroup = $this->block;
35 6
        $class = $formGroup->getAttribute('class').'form-group';
36 6
        $formGroup->setAttribute('class', $class);
37
38
        // add the label div, form field, and error div, if any.
39 6
        if (!$this->field instanceof Radio && !$this->field instanceof CheckBox) {
40 6
            $formGroup->appendChild($this->label);
41 6
        }
42
43 6
        $formGroup->appendChild($this->element);
44
45 6
        if (!is_null($this->errors)) {
46 2
            $formGroup->appendChild($this->errors);
47 2
        }
48
49
        // Field rendered! Pass it back!
50 6
        return $formGroup;
51
    }
52
53
}