Passed
Pull Request — master (#721)
by Florian
02:40
created

InputDate::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 1
eloc 10
c 2
b 1
f 0
nc 1
nop 10
dl 0
loc 17
ccs 0
cts 11
cp 0
crap 2
rs 9.9332

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 JeroenNoten\LaravelAdminLte\Components;
4
5
use Illuminate\View\Component;
6
7
class InputDate extends Component
8
{
9
    public $id;
10
    public $name;
11
    public $label;
12
    public $placeholder;
13
    public $topclass;
14
    public $inputclass;
15
    public $value;
16
    public $disabled;
17
    public $required;
18
    public $format;
19
20
    public function __construct(
21
            $id, $name = null,
22
            $label = 'Input Label', $placeholder = null,
23
            $topclass = null, $inputclass = null,
24
            $value = null, $disabled = false, $required = false,
25
            $format = 'YYYY-MM-DD'
26
        ) {
27
        $this->id = $id;
28
        $this->name = $name;
29
        $this->label = $label;
30
        $this->placeholder = $placeholder;
31
        $this->topclass = $topclass;
32
        $this->inputclass = $inputclass;
33
        $this->value = $value;
34
        $this->required = $required;
35
        $this->disabled = $disabled;
36
        $this->format = $format;
37
    }
38
39
    public function render()
40
    {
41
        return view('adminlte::components.input-date');
42
    }
43
}
44