Passed
Pull Request — 2.x (#1360)
by Harings
11:27
created

Input   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 36 1
A render() 0 4 2
1
<?php
2
3
namespace A17\Twill\View\Components;
4
5
class Input extends TwillFormComponent
6
{
7
    public $type;
8
    public $translated;
9
    public $required;
10
    public $placeholder;
11
    public $maxlength;
12
    public $readonly;
13
    public $rows;
14
    public $ref;
15
    public $onChange;
16
    public $onChangeAttribute;
17
    public $prefix;
18
    public $inModal;
19
    public $note;
20
    public $disabled;
21
    public $default;
22
23
    public function __construct(
24
        $name,
25
        $label,
26
        $type = 'text',
27
        $translated = false,
28
        $required = false,
29
        $note = null,
30
        $placeholder = null,
31
        $maxlength = null,
32
        $disabled = false,
33
        $readonly = false,
34
        $default = null,
35
        $rows = null,
36
        $ref = null,
37
        $onChange = null,
38
        $onChangeAttribute = null,
39
        $prefix = null,
40
        $inModal = false
41
    ) {
42
        parent::__construct($name, $label);
43
44
        $this->type = $type;
45
        $this->translated = $translated;
46
        $this->required = $required;
47
        $this->note = $note;
48
        $this->placeholder = $placeholder;
49
        $this->maxlength = $maxlength;
50
        $this->disabled = $disabled;
51
        $this->readonly = $readonly;
52
        $this->default = $default;
53
        $this->rows = $rows;
54
        $this->ref = $ref;
55
        $this->onChange = $onChange;
56
        $this->onChangeAttribute = $onChangeAttribute;
57
        $this->prefix = $prefix;
58
        $this->inModal = $inModal;
59
    }
60
61
    public function render()
62
    {
63
        return view('twill::partials.form._input', [
64
            'onChangeFullAttribute' => $this->onChangeAttribute ? "('".$this->onChangeAttribute."', ...arguments)" : "",
65
        ]);
66
    }
67
}
68