Conditions | 4 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
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 | } |
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.