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

Textarea::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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

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