Passed
Push — master ( bd59c3...bb2815 )
by Pascal
05:04 queued 03:02
created

FormInput::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 19
rs 10
cc 2
nc 2
nop 7
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