Completed
Push — master ( dc27cd...c0eb3b )
by Rasmus
07:46
created

TextArea   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 34
ccs 10
cts 11
cp 0.9091
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A renderInput() 0 18 3
1
<?php
2
3
namespace mindplay\kissform\Fields;
4
5
use mindplay\kissform\InputModel;
6
use mindplay\kissform\InputRenderer;
7
8
/**
9
 * This class represents an HTML <textarea> element.
10
 */
11
class TextArea extends TextField
12
{
13
    /**
14
     * @var int|null visible number of lines in the textarea
15
     */
16
    public $rows = null;
17
18
    /**
19
     * @var int|null visible width of the textarea
20
     */
21
    public $cols = null;
22
23
    /**
24
     * {@inheritdoc}
25
     */
26 1
    public function renderInput(InputRenderer $renderer, InputModel $model, array $attr)
27
    {
28
        $attr += [
29 1
            'name' => $renderer->getName($this),
30 1
            'id' => $renderer->getId($this),
31 1
            'placeholder' => @$attr['placeholder'] ?: $renderer->getPlaceholder($this),
32
        ];
33
34 1
        $attr['class'] = isset($attr['class'])
35
            ? array_merge([$renderer->input_class], (array) $attr['class'])
36 1
            : $renderer->input_class;
37
38 1
        return $renderer->tag(
39 1
            'textarea',
40 1
            $attr,
41 1
            $renderer->escape($model->getInput($this))
0 ignored issues
show
Bug introduced by
It seems like $model->getInput($this) targeting mindplay\kissform\InputModel::getInput() can also be of type array or null; however, mindplay\kissform\InputRenderer::escape() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
42
        );
43
    }
44
}
45