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

SelectIcon::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 8
dl 0
loc 14
ccs 0
cts 9
cp 0
crap 2
rs 10

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 SelectIcon extends Component
8
{
9
    public $id;
10
    public $name;
11
    public $label;
12
    public $topclass;
13
    public $inputclass;
14
    public $disabled;
15
    public $required;
16
    public $multiple;
17
18
    public function __construct(
19
            $id, $name = null,
20
            $label = 'Input Label',
21
            $topclass = null, $inputclass = null,
22
            $disabled = false, $required = false, $multiple = false
23
        ) {
24
        $this->id = $id;
25
        $this->name = $name;
26
        $this->label = $label;
27
        $this->topclass = $topclass;
28
        $this->inputclass = $inputclass;
29
        $this->required = $required;
30
        $this->disabled = $disabled;
31
        $this->multiple = $multiple;
32
    }
33
34
    public function render()
35
    {
36
        return view('adminlte::components.select-icon');
37
    }
38
}
39