Passed
Push — master ( 8f6522...eef865 )
by Florian
06:34
created

InfoBox::__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 0
Metric Value
cc 1
eloc 8
nc 1
nop 8
dl 0
loc 13
ccs 9
cts 9
cp 1
crap 1
rs 10
c 0
b 0
f 0

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\View\Components\Widget;
4
5
use Illuminate\View\Component;
6
7
class InfoBox extends Component
8
{
9
    /**
10
     * The title/header for the box.
11
     *
12
     * @var string
13
     */
14
    public $title;
15
16
    /**
17
     * A short text description for the box.
18
     *
19
     * @var string
20
     */
21
    public $text;
22
23
    /**
24
     * A long description for the box.
25
     *
26
     * @var string
27
     */
28
    public $description;
29
30
    /**
31
     * A Font Awesome icon for the box.
32
     *
33
     * @var string
34
     */
35
    public $icon;
36
37
    /**
38
     * The box theme (light, dark, primary, secondary, info, success, warning,
39
     * danger or any other AdminLTE color like lighblue or teal).
40
     *
41
     * @var string
42
     */
43
    public $theme;
44
45
    /**
46
     * The icon theme (light, dark, primary, secondary, info, success, warning,
47
     * danger or any other AdminLTE color like lighblue or teal).
48
     *
49
     * @var string
50
     */
51
    public $iconTheme;
52
53
    /**
54
     * Enables a progress bar for the box. The value should be an integer
55
     * indicating the percentage of the progress bar.
56
     *
57
     * @var int
58
     */
59
    public $progress;
60
61
    /**
62
     * The progress bar theme (light, dark, primary, secondary, info, success,
63
     * warning, danger or any other AdminLTE color like lighblue or teal).
64
     *
65
     * @var string
66
     */
67
    public $progressTheme;
68
69
    /**
70
     * Create a new component instance.
71
     *
72
     * @return void
73
     */
74 2
    public function __construct(
75
        $title = null, $text = null, $icon = null, $description = null,
76
        $theme = null, $iconTheme = null, $progress = null,
77
        $progressTheme = 'white'
78
    ) {
79 2
        $this->title = $title;
80 2
        $this->text = $text;
81 2
        $this->icon = $icon;
82 2
        $this->description = $description;
83 2
        $this->theme = $theme;
84 2
        $this->iconTheme = $iconTheme;
85 2
        $this->progress = $progress;
86 2
        $this->progressTheme = $progressTheme;
87 2
    }
88
89
    /**
90
     * Make the box class.
91
     *
92
     * @return string
93
     */
94 1
    public function makeBoxClass()
95
    {
96 1
        $classes = ['info-box'];
97
98 1
        if (isset($this->theme)) {
99 1
            $classes[] = "bg-{$this->theme}";
100
        }
101
102 1
        return implode(' ', $classes);
103
    }
104
105
    /**
106
     * Make the icon container class.
107
     *
108
     * @return string
109
     */
110 1
    public function makeIconClass()
111
    {
112 1
        $classes = ['info-box-icon'];
113
114 1
        if (isset($this->iconTheme)) {
115 1
            $classes[] = "bg-{$this->iconTheme}";
116
        }
117
118 1
        return implode(' ', $classes);
119
    }
120
121
    /**
122
     * Get the view / contents that represent the component.
123
     *
124
     * @return \Illuminate\View\View|string
125
     */
126 1
    public function render()
127
    {
128 1
        return view('adminlte::components.widget.info-box');
129
    }
130
}
131