Passed
Push — master ( 4c5faf...429320 )
by Chris
04:23
created

Label::renderHtmlMarkup()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace WebTheory\Saveyour\Elements;
4
5
use WebTheory\Html\AbstractHtmlElement;
6
7
class Label extends AbstractHtmlElement
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $content;
13
14
    /**
15
     * @var string
16
     */
17
    protected $for;
18
19
    /**
20
     *
21
     */
22 6
    public function __construct(string $content)
23
    {
24 6
        $this->content = $content;
25
26 6
        parent::__construct();
27 6
    }
28
29
    /**
30
     * Get the value of content
31
     *
32
     * @return string
33
     */
34 6
    public function getContent(): string
35
    {
36 6
        return $this->content;
37
    }
38
39
    /**
40
     * Get the value of for
41
     *
42
     * @return mixed
43
     */
44 3
    public function getFor()
45
    {
46 3
        return $this->for;
47
    }
48
49
    /**
50
     * Set the value of for
51
     *
52
     * @param mixed $for
53
     *
54
     * @return self
55
     */
56 6
    public function setFor($for)
57
    {
58 6
        $this->for = $for;
59
60 6
        return $this;
61
    }
62
63
    /**
64
     *
65
     */
66 3
    protected function resolveAttributes(): AbstractHtmlElement
67
    {
68 3
        return parent::resolveAttributes()
69 3
            ->addAttribute('for', $this->for);
0 ignored issues
show
Bug introduced by
'for' of type string is incompatible with the type array expected by parameter $attribute of WebTheory\Html\AbstractHtmlElement::addAttribute(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

69
            ->addAttribute(/** @scrutinizer ignore-type */ 'for', $this->for);
Loading history...
70
    }
71
72
    /**
73
     *
74
     */
75 3
    protected function renderHtmlMarkup(): string
76
    {
77 3
        return $this->tag('label', $this->attributes, $this->content);
78
    }
79
}
80