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

SelectRender   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 88.89%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 23
ccs 8
cts 9
cp 0.8889
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A renderBlock() 0 13 3
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
}