Completed
Push — master ( a94554...39eef4 )
by Costin
02:09
created

Input   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setType() 0 4 3
A setSpecificAttributes() 0 4 1
A setPlaceholder() 0 4 3
A attributesList() 0 4 1
A setDefaultClass() 0 3 1
1
<?php
2
3
namespace SoareCostin\BladeFormComponents\FormElements;
4
5
use SoareCostin\BladeFormComponents\FormElement;
6
7
class Input extends FormElement
8
{
9
    /** @var string */
10
    public $type = 'text';
11
12
    /** @var string */
13
    public $placeholder;
14
15
    protected function attributesList()
16
    {
17
        return [
18
            'id', 'name', 'type', 'placeholder', 'value', 'class', 'required', 'disabled', 'readonly', 'autocomplete',
19
        ];
20
    }
21
22
    protected function setSpecificAttributes()
23
    {
24
        $this->setPlaceholder();
25
        $this->setType();
26
    }
27
28
    protected function setPlaceholder()
29
    {
30
        if (isset($this->params['placeholder']) && ! empty($this->params['placeholder'])) {
31
            $this->placeholder = $this->params['placeholder'];
32
        }
33
    }
34
35
    protected function setType()
36
    {
37
        if (isset($this->params['type']) && ! empty($this->params['type'])) {
38
            $this->type = $this->params['type'];
39
        }
40
    }
41
42
    protected function setDefaultClass()
43
    {
44
        $this->class[] = config('blade-form-components.themes.'.$this->getTheme().'.fields.input');
45
    }
46
}
47