Passed
Pull Request — master (#721)
by Florian
03:35
created

SmallBox::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

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 13
ccs 9
cts 9
cp 1
crap 1
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 SmallBox extends Component
8
{
9
    public $bg;
10
    public $icon;
11
    public $title;
12
    public $text;
13
    public $url;
14
    public $urlText;
15
    public $loading;
16
    public $id;
17
18 2
    public function __construct(
19
        $bg = 'info', $icon = 'fas fa-star', $title, $id = null,
20
        $text, $url = '#', $urlText = null,
21
        $loading = false)
22
    {
23 2
        $this->id = $id;
24 2
        $this->bg = $bg;
25 2
        $this->icon = $icon;
26 2
        $this->title = $title;
27 2
        $this->text = $text;
28 2
        $this->url = $url;
29 2
        $this->urlText = $urlText;
30 2
        $this->loading = $loading;
31 2
    }
32
33 1
    public function urlTextLine()
34
    {
35 1
        return ($this->urlText == null) ? 'More Info' : $this->urlText;
36
    }
37
38 1
    public function render()
39
    {
40 1
        return view('adminlte::components.small-box');
41
    }
42
}
43