Completed
Branch dev-master (5a9550)
by Derek Stephen
02:00
created

SelectRender::renderBlock()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3.0123

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 8
cts 9
cp 0.8889
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 9
nc 3
nop 2
crap 3.0123
1
<?php
2
/**
3
 * User: delboy1978uk
4
 * Date: 04/12/2016
5
 * Time: 22:33
6
 */
7
8
namespace Del\Form\Renderer\Field;
9
10
use Del\Form\Field\FieldInterface;
11
use Del\Form\Field\Select;
12
use DOMElement;
13
use InvalidArgumentException;
14
15
class SelectRender extends AbstractFieldRender implements FieldRendererInterface
16
{
17
    /**
18
     * @param FieldInterface $field
19
     * @param DOMElement $fieldBlock
0 ignored issues
show
Bug introduced by
There is no parameter named $fieldBlock. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
20
     * @param DOMElement $labelBlock
0 ignored issues
show
Bug introduced by
There is no parameter named $labelBlock. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
21
     * @param DOMElement $element
22
     * @param DOMElement|null $errorBlock
0 ignored issues
show
Bug introduced by
There is no parameter named $errorBlock. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
23
     */
24 1
    public function renderBlock(FieldInterface $field, DOMElement $element)
25
    {
26 1
        if (!$field instanceof Select) {
27
            throw new InvalidArgumentException('Must be a Del\Form\Field\Select');
28
        }
29 1
        foreach ($field->getOptions() as $value => $label) {
30 1
            $option = $this->dom->createElement('option');
31 1
            $option->setAttribute('value', $value);
32 1
            $option->textContent = $label;
33 1
            $element->appendChild($option);
34
        }
35 1
        return $element;
36
    }
37
}