Completed
Push — master ( 57186d...a3ca22 )
by Sebastian
01:30
created

Input   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 114
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 114
rs 10
c 0
b 0
f 0
wmc 14
lcom 1
cbo 1

11 Methods

Rating   Name   Duplication   Size   Complexity  
A autofocus() 0 4 1
A checked() 0 6 2
A disabled() 0 6 2
A name() 0 4 1
A placeholder() 0 4 1
A required() 0 6 2
A type() 0 4 1
A unchecked() 0 4 1
A value() 0 4 1
A readonly() 0 4 1
A size() 0 4 1
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
     * @param bool $required
65
     *
66
     * @return static
67
     */
68
    public function required($required = true)
69
    {
70
        return $required
71
            ? $this->attribute('required')
72
            : $this->forgetAttribute('required');
73
    }
74
75
    /**
76
     * @param string|null $type
77
     *
78
     * @return static
79
     */
80
    public function type($type)
81
    {
82
        return $this->attribute('type', $type);
83
    }
84
85
    /**
86
     * @return static
87
     */
88
    public function unchecked()
89
    {
90
        return $this->checked(false);
91
    }
92
93
    /**
94
     * @param string|null $value
95
     *
96
     * @return static
97
     */
98
    public function value($value)
99
    {
100
        return $this->attribute('value', $value);
101
    }
102
103
    /**
104
     * @return static
105
     */
106
    public function readonly()
107
    {
108
        return $this->attribute('readonly');
109
    }
110
111
    /**
112
     * @param string|null $size
113
     *
114
     * @return static
115
     */
116
    public function size($size)
117
    {
118
        return $this->attribute('size', $size);
119
    }
120
}
121