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

DatePicker::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 13
c 1
b 0
f 0
nc 1
nop 16
dl 0
loc 31
rs 9.8333

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 DatePicker extends TwillFormComponent
6
{
7
    public $withTime;
8
    public $allowInput;
9
    public $allowClear;
10
    public $note;
11
    public $inModal;
12
    public $timeOnly;
13
    public $placeholder;
14
    public $required;
15
    public $time24Hr;
16
    public $altFormat;
17
    public $hourIncrement;
18
    public $minuteIncrement;
19
20
    public function __construct(
21
        $name,
22
        $label,
23
        $renderForBlocks = false,
24
        $renderForModal = false,
25
        $withTime = true,
26
        $allowInput = false,
27
        $allowClear = false,
28
        $note = null,
29
        $inModal = false,
30
        $placeholder = '',
31
        $timeOnly = false,
32
        $required = false,
33
        $time24Hr = false,
34
        $altFormat = null,
35
        $hourIncrement = null,
36
        $minuteIncrement = null
37
    ) {
38
        parent::__construct($name, $label, $renderForBlocks, $renderForModal);
39
        $this->withTime = $withTime;
40
        $this->allowInput = $allowInput;
41
        $this->allowClear = $allowClear;
42
        $this->note = $note;
43
        $this->inModal = $inModal;
44
        $this->timeOnly = $timeOnly;
45
        $this->placeholder = $placeholder;
46
        $this->required = $required;
47
        $this->time24Hr = $time24Hr;
48
        $this->altFormat = $altFormat;
49
        $this->hourIncrement = $hourIncrement;
50
        $this->minuteIncrement = $minuteIncrement;
51
    }
52
53
    public function render()
54
    {
55
        return view('twill::partials.form._date_picker');
56
    }
57
}
58