Completed
Pull Request — master (#105)
by lee
01:42
created

Option::undisabled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Spatie\Html\Elements;
4
5
use Spatie\Html\Selectable;
6
use Spatie\Html\Disabledable;
7
use Spatie\Html\BaseElement;
8
9
class Option extends BaseElement implements Selectable, Disabledable
10
{
11
    /** @var string */
12
    protected $tag = 'option';
13
14
    /**
15
     * @return static
16
     */
17
    public function selected()
18
    {
19
        return $this->attribute('selected', 'selected');
20
    }
21
22
    /**
23
     * @return static
24
     */
25
    public function disabled()
26
    {
27
        return $this->attribute('disabled', 'disabled');
28
    }
29
30
    /**
31
     * @param bool $condition
32
     *
33
     * @return static
34
     */
35
    public function selectedIf($condition)
36
    {
37
        return $condition ?
38
            $this->selected() :
39
            $this->unselected();
40
    }
41
42
    /**
43
     * @param bool $condition
44
     *
45
     * @return static
46
     */
47
    public function disabledIf($condition)
48
    {
49
        return $condition ?
50
            $this->disabled() :
51
            $this->undisabled();
52
    }
53
54
    /**
55
     * @return static
56
     */
57
    public function unselected()
58
    {
59
        return $this->forgetAttribute('selected');
60
    }
61
62
    /**
63
     * @return static
64
     */
65
    public function undisabled()
66
    {
67
        return $this->forgetAttribute('disabled');
68
    }
69
70
    /**
71
     * @param string|null $value
72
     *
73
     * @return static
74
     */
75
    public function value($value)
76
    {
77
        return $this->attribute('value', $value);
78
    }
79
}
80