Password::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
cc 2
nc 2
nop 6
1
<?php
2
3
namespace Aminetiyal\LaravelTemplate\Components\Lte\Field;
4
5
use Illuminate\View\Component;
6
use Illuminate\Support\Str;
7
8
9
class Password extends Component
10
{
11
    public $name;
12
    public $label;
13
    public $placeholder;
14
    public $class;
15
    public $required;
16
    public $icon;
17
18
    public function __construct(
19
        $name = null,
20
        $label = null,
21
        $placeholder = null,
22
        $class = null,
23
        $required = false,
24
        $icon = null
25
    )
26
    {
27
        $this->label = $label;
28
        $this->setName($name);
29
        $this->placeholder = $placeholder ?? (!$name ? str_replace('-', '_', Str::kebab($label)) : '');
30
        $this->class = $class;
31
        $this->required = $required;
32
        $this->icon = $icon;
33
    }
34
35
    public function setName($name): void
36
    {
37
        if ($this->label == 'Confirmation') {
38
            $this->name = $name ?? 'password_confirmation';
39
        } else {
40
            $this->name = $name ?? 'password';
41
        }
42
    }
43
44
    public function render()
45
    {
46
        return view('template::lte.components._fields.password');
47
    }
48
}
49