Passed
Pull Request — master (#721)
by Florian
09:26
created

InputDate::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 10
dl 0
loc 18
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, $name, $label, $placeholder;
10
    public $topclass, $inputclass;
11
    public $value, $disabled, $required;
12
    public $format;
13
14
    public function __construct(
15
            $id, $name = null,
16
            $label = 'Input Label', $placeholder = null,
17
            $topclass = null, $inputclass = null,
18
            $value = null, $disabled = false, $required = false,
19
            $format = 'YYYY-MM-DD'
20
        )
21
    {
22
        $this->id = $id;
23
        $this->name = $name;
24
        $this->label = $label;
25
        $this->placeholder = $placeholder;
26
        $this->topclass = $topclass;
27
        $this->inputclass = $inputclass;
28
        $this->value = $value;
29
        $this->required = $required;
30
        $this->disabled = $disabled;
31
        $this->format = $format;
32
    }
33
34
    public function render()
35
    {
36
        return view('adminlte::input-date');
37
    }
38
}