Completed
Pull Request — master (#52)
by
unknown
01:22
created

Input   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 92
rs 10
wmc 10
lcom 1
cbo 2

9 Methods

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