FormInput   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 16
c 1
b 0
f 0
dl 0
loc 38
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 21 3
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
    public bool $floating;
14
15
    public $value;
16
17
    /**
18
     * Create a new component instance.
19
     *
20
     * @return void
21
     */
22
    public function __construct(
23
        string $name,
24
        string $label = '',
25
        string $type = 'text',
26
        $bind = null,
27
        $default = null,
28
        $language = null,
29
        bool $showErrors = true,
30
        bool $floating = false
31
    ) {
32
        $this->name       = $name;
33
        $this->label      = $label;
34
        $this->type       = $type;
35
        $this->showErrors = $showErrors;
36
        $this->floating   = $floating && $type !== 'hidden';
37
38
        if ($language) {
39
            $this->name = "{$name}[{$language}]";
40
        }
41
42
        $this->setValue($name, $bind, $default, $language);
43
    }
44
}
45