OptGroup   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 48
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setDisabled() 0 5 1
A isDisabled() 0 3 1
A renderHtmlMarkup() 0 3 1
A resolveAttributes() 0 7 1
1
<?php
2
3
namespace WebTheory\Saveyour\Field\Element;
4
5
use WebTheory\Saveyour\Field\Abstracts\AbstractValuableElement;
6
use WebTheory\Saveyour\Field\Abstracts\MultiValueSelectionTrait;
7
use WebTheory\Saveyour\Field\Abstracts\RendersOptionsTrait;
8
9
class OptGroup extends AbstractValuableElement
10
{
11
    use MultiValueSelectionTrait;
12
    use RendersOptionsTrait;
13
14
    protected $value = [];
15
16
    protected string $label;
17
18
    protected bool $disabled = false;
19
20
    public function __construct(string $label)
21
    {
22
        $this->label = $label;
23
24
        parent::__construct();
25
    }
26
27
    public function isDisabled(): bool
28
    {
29
        return $this->disabled;
30
    }
31
32
    /**
33
     * @return $this
34
     */
35
    public function setDisabled(bool $disabled): OptGroup
36
    {
37
        $this->disabled = $disabled;
38
39
        return $this;
40
    }
41
42
    /**
43
     * @return $this
44
     */
45
    protected function resolveAttributes(): OptGroup
46
    {
47
        parent::resolveAttributes()
48
            ->addAttribute('label', $this->label)
49
            ->addAttribute('disabled', $this->disabled);
50
51
        return $this;
52
    }
53
54
    protected function renderHtmlMarkup(): string
55
    {
56
        return $this->tag('optgroup', $this->attributes, $this->renderSelection());
57
    }
58
}
59