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

TextArea::renderInput()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3.0067

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 10
cts 11
cp 0.9091
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 12
nc 4
nop 3
crap 3.0067
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