Textarea::setRows()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace WebTheory\Saveyour\Field\Type;
4
5
use WebTheory\Saveyour\Contracts\Field\FormFieldInterface;
6
use WebTheory\Saveyour\Field\Type\Abstracts\AbstractStandardFormControl;
7
8
class Textarea extends AbstractStandardFormControl implements FormFieldInterface
9
{
10
    public ?int $rows = null;
11
12
    /**
13
     * Get the value of rows
14
     *
15
     * @return int
16
     */
17
    public function getRows(): int
18
    {
19
        return $this->rows;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->rows could return the type null which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
20
    }
21
22
    /**
23
     * Set the value of rows
24
     *
25
     * @param int $rows
26
     *
27
     * @return $this
28
     */
29
    public function setRows(int $rows): Textarea
30
    {
31
        $this->rows = $rows;
32
33
        return $this;
34
    }
35
36
    /**
37
     * @return $this
38
     */
39
    protected function resolveAttributes(): Textarea
40
    {
41
        parent::resolveAttributes()
42
            ->addAttribute('rows', $this->rows);
43
44
        return $this;
45
    }
46
47
    protected function renderHtmlMarkup(): string
48
    {
49
        return $this->tag('textarea', $this->attributes, $this->value);
50
    }
51
}
52