Passed
Pull Request — master (#832)
by Florian
09:14
created

InfoBox::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
nc 1
nop 8
dl 0
loc 13
rs 10
c 1
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\Components;
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
    public function __construct(
75
        $title = null, $text = null, $icon = null, $description = null,
76
        $theme = null, $iconTheme = null, $progress = null,
77
        $progressTheme = 'white'
78
    ) {
79
        $this->title = $title;
80
        $this->text = $text;
81
        $this->icon = $icon;
82
        $this->description = $description;
83
        $this->theme = $theme;
84
        $this->iconTheme = $iconTheme;
85
        $this->progress = $progress;
86
        $this->progressTheme = $progressTheme;
87
    }
88
89
    /**
90
     * Make the box class.
91
     *
92
     * @return string
93
     */
94
    public function makeBoxClass()
95
    {
96
        $classes = ['info-box'];
97
98
        if (isset($this->theme)) {
99
            $classes[] = "bg-{$this->theme}";
100
        }
101
102
        return implode(' ', $classes);
103
    }
104
105
    /**
106
     * Make the icon container class.
107
     *
108
     * @return string
109
     */
110
    public function makeIconClass()
111
    {
112
        $classes = ['info-box-icon'];
113
114
        if (isset($this->iconTheme)) {
115
            $classes[] = "bg-{$this->iconTheme}";
116
        }
117
118
        return implode(' ', $classes);
119
    }
120
121
    /**
122
     * Get the view / contents that represent the component.
123
     *
124
     * @return \Illuminate\View\View|string
125
     */
126
    public function render()
127
    {
128
        return view('adminlte::components.info-box');
129
    }
130
}
131