Completed
Push — master ( b4108d...a625ee )
by Sebastian
03:05
created

Input::disabled()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Spatie\Html\Elements;
4
5
use Spatie\Html\BaseElement;
6
7
class Input extends BaseElement
8
{
9
    protected $tag = 'input';
10
11
    /**
12
     * @return static
13
     */
14
    public function autofocus()
15
    {
16
        return $this->attribute('autofocus');
17
    }
18
19
    /**
20
     * @param bool $checked
21
     *
22
     * @return static
23
     */
24
    public function checked($checked = true)
25
    {
26
        return $checked
27
            ? $this->attribute('checked', 'checked')
28
            : $this->forgetAttribute('checked');
29
    }
30
31
    /**
32
     * @param bool $disabled
33
     *
34
     * @return static
35
     */
36
    public function disabled($disabled = true)
37
    {
38
        return $disabled
39
            ? $this->attribute('disabled', 'disabled')
40
            : $this->forgetAttribute('disabled');
41
    }
42
43
    /**
44
     * @param string|null $name
45
     *
46
     * @return static
47
     */
48
    public function name($name)
49
    {
50
        return $this->attribute('name', $name);
51
    }
52
53
    /**
54
     * @param string|null $placeholder
55
     *
56
     * @return static
57
     */
58
    public function placeholder($placeholder)
59
    {
60
        return $this->attribute('placeholder', $placeholder);
61
    }
62
63
    /**
64
     * @return static
65
     */
66
    public function required()
67
    {
68
        return $this->attribute('required');
69
    }
70
71
    /**
72
     * @param string|null $type
73
     *
74
     * @return static
75
     */
76
    public function type($type)
77
    {
78
        return $this->attribute('type', $type);
79
    }
80
81
    /**
82
     * @return static
83
     */
84
    public function unchecked()
85
    {
86
        return $this->checked(false);
87
    }
88
89
    /**
90
     * @param string|null $value
91
     *
92
     * @return static
93
     */
94
    public function value($value)
95
    {
96
        return $this->attribute('value', $value);
97
    }
98
99
    /**
100
     * @return static
101
     */
102
    public function readonly()
103
    {
104
        return $this->attribute('readonly');
105
    }
106
}
107