Label::renderHtmlMarkup()   A
last analyzed

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
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace WebTheory\Saveyour\Field\Element;
4
5
use WebTheory\Html\AbstractHtmlElement;
6
7
class Label extends AbstractHtmlElement
8
{
9
    protected string $content;
10
11
    protected ?string $for = null;
12
13 6
    public function __construct(string $content)
14
    {
15 6
        $this->content = $content;
16
17 6
        parent::__construct();
18
    }
19
20
    /**
21
     * Get the value of content
22
     *
23
     * @return string
24
     */
25 6
    public function getContent(): string
26
    {
27 6
        return $this->content;
28
    }
29
30
    /**
31
     * Get the value of for
32
     *
33
     * @return mixed
34
     */
35 3
    public function getFor()
36
    {
37 3
        return $this->for;
38
    }
39
40
    /**
41
     * Set the value of for
42
     *
43
     * @param mixed $for
44
     *
45
     * @return $this
46
     */
47 6
    public function setFor($for): Label
48
    {
49 6
        $this->for = $for;
50
51 6
        return $this;
52
    }
53
54
    /**
55
     * @return $this
56
     */
57 3
    protected function resolveAttributes(): Label
58
    {
59 3
        parent::resolveAttributes()
60 3
            ->addAttribute('for', $this->for);
61
62 3
        return $this;
63
    }
64
65 3
    protected function renderHtmlMarkup(): string
66
    {
67 3
        return $this->tag('label', $this->attributes, $this->content);
68
    }
69
}
70