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

Input   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 38 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
        $renderForBlocks = false,
42
        $renderForModal = false
43
    ) {
44
        parent::__construct($name, $label, $renderForBlocks, $renderForModal);
45
46
        $this->type = $type;
47
        $this->translated = $translated;
48
        $this->required = $required;
49
        $this->note = $note;
50
        $this->placeholder = $placeholder;
51
        $this->maxlength = $maxlength;
52
        $this->disabled = $disabled;
53
        $this->readonly = $readonly;
54
        $this->default = $default;
55
        $this->rows = $rows;
56
        $this->ref = $ref;
57
        $this->onChange = $onChange;
58
        $this->onChangeAttribute = $onChangeAttribute;
59
        $this->prefix = $prefix;
60
        $this->inModal = $inModal;
61
    }
62
63
    public function render()
64
    {
65
        return view('twill::partials.form._input', [
66
            'onChangeFullAttribute' => $this->onChangeAttribute ? "('".$this->onChangeAttribute."', ...arguments)" : "",
67
        ]);
68
    }
69
}
70