Passed
Pull Request — master (#8)
by Pascal
03:05
created

FormInput   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 14
c 1
b 0
f 0
dl 0
loc 35
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 2
1
<?php
2
3
namespace ProtoneMedia\LaravelFormComponents\Components;
4
5
class FormInput extends Component
6
{
7
    use HandlesValidationErrors;
8
    use HandlesDefaultAndOldValue;
9
10
    public string $name;
11
    public string $label;
12
    public string $type;
13
14
    public $value;
15
16
    /**
17
     * Create a new component instance.
18
     *
19
     * @return void
20
     */
21
    public function __construct(
22
        string $name,
23
        string $label = '',
24
        string $type = 'text',
25
        $bind = null,
26
        $default = null,
27
        $language = null,
28
        bool $showErrors = true
29
    ) {
30
        $this->name       = $name;
31
        $this->label      = $label;
32
        $this->type       = $type;
33
        $this->showErrors = $showErrors;
34
35
        if ($language) {
36
            $this->name = "{$name}[{$language}]";
37
        }
38
39
        $this->setValue($name, $bind, $default, $language);
40
    }
41
}
42