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

MultiSelect::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 36
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 17
c 1
b 0
f 0
nc 1
nop 16
dl 0
loc 36
rs 9.7

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace A17\Twill\View\Components;
4
5
class MultiSelect extends FieldWithOptions
6
{
7
    public $min;
8
    public $max;
9
10
    public function __construct(
11
        $name,
12
        $label,
13
        $options = [],
14
        $unpack = false,
15
        $columns = 0,
16
        $searchable = false,
17
        $note = null,
18
        $placeholder = null,
19
        $disabled = false,
20
        $addNew = false,
21
        $moduleName = null,
22
        $default = false,
23
        $storeUrl = null,
24
        $fieldsInModal = null,
25
        $min = null,
26
        $max = null
27
    ) {
28
        parent::__construct(
29
            $name,
30
            $label,
31
            $options,
32
            $unpack,
33
            $columns,
34
            $searchable,
35
            $note,
36
            $placeholder,
37
            $disabled,
38
            $addNew,
39
            $moduleName,
40
            $storeUrl,
41
            $default,
42
            $fieldsInModal
43
        );
44
        $this->min = $min;
45
        $this->max = $max;
46
    }
47
48
    public function render()
49
    {
50
        return view('twill::partials.form._multi_select', [
51
            'options' => $this->getOptions(),
52
            'inModal' => $this->inModal()
53
        ]);
54
    }
55
}
56