Passed
Pull Request — master (#721)
by Florian
14:00 queued 04:02
created

InfoBox::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 9
dl 0
loc 14
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 InfoBox extends Component
8
{
9
    public $bg;
10
    public $icon;
11
    public $title;
12
    public $text;
13
    public $full;
14
    public $grad;
15
    public $id;
16
    public $progress;
17
    public $comment;
18
19
    public function __construct(
20
        $bg = 'info', $icon = 'fas fa-star', $id = null,
21
        $title, $text, $full = false, $grad = false,
22
        $progress = false, $comment = false)
23
    {
24
        $this->id = $id;
25
        $this->bg = $bg;
26
        $this->icon = $icon;
27
        $this->title = $title;
28
        $this->text = $text;
29
        $this->full = $full;
30
        $this->grad = $grad;
31
        $this->progress = $progress;
32
        $this->comment = $comment;
33
    }
34
35
    public function background()
36
    {
37
        return $this->full ? ($this->grad ? 'bg-gradient-' : 'bg-').$this->bg : '';
38
    }
39
40
    public function foreground()
41
    {
42
        return ! $this->full ? ($this->grad ? 'bg-gradient-' : 'bg-').$this->bg : '';
43
    }
44
45
    public function render()
46
    {
47
        return view('adminlte::info-box');
48
    }
49
}
50