Passed
Pull Request — master (#721)
by Florian
05:31
created

ProfileWidget   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 132
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 30
dl 0
loc 132
ccs 28
cts 28
cp 1
rs 10
c 2
b 1
f 0
wmc 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A makeHeaderStyle() 0 9 2
A makeFooterClass() 0 9 2
A render() 0 3 1
A makeHeaderClass() 0 13 4
A __construct() 0 11 1
1
<?php
2
3
namespace JeroenNoten\LaravelAdminLte\Components;
4
5
use Illuminate\View\Component;
6
7
class ProfileWidget extends Component
8
{
9
    /**
10
     * The user name of the profile widget.
11
     *
12
     * @var string
13
     */
14
    public $name;
15
16
    /**
17
     * The user description of the profile widget.
18
     *
19
     * @var string
20
     */
21
    public $desc;
22
23
    /**
24
     * The user image of the profile widget.
25
     *
26
     * @var string
27
     */
28
    public $img;
29
30
    /**
31
     * The profile header theme (light, dark, primary, secondary, info, success,
32
     * warning, danger or any other AdminLTE color like lighblue or teal).
33
     *
34
     * @var string
35
     */
36
    public $theme;
37
38
    /**
39
     * The profile header image cover. Overlays the header theme.
40
     *
41
     * @var string
42
     */
43
    public $cover;
44
45
    /**
46
     * Extra classes for the profile header. This provides a way to customize
47
     * the header style.
48
     *
49
     * @var string
50
     */
51
    public $headerClass;
52
53
    /**
54
     * Extra classes for the profile footer. This provides a way to customize
55
     * the footer style.
56
     *
57
     * @var string
58
     */
59
    public $footerClass;
60
61
    /**
62
     * Create a new component instance.
63
     *
64
     * @return void
65
     */
66 2
    public function __construct(
67
        $name = null, $desc = null, $img = null, $theme = null, $cover = null,
68
        $headerClass = null, $footerClass = null
69
    ) {
70 2
        $this->name = $name;
71 2
        $this->desc = $desc;
72 2
        $this->img = $img;
73 2
        $this->theme = $theme;
74 2
        $this->cover = $cover;
75 2
        $this->headerClass = $headerClass;
76 2
        $this->footerClass = $footerClass;
77 2
    }
78
79
    /**
80
     * Make the profile header class.
81
     *
82
     * @return string
83
     */
84 1
    public function makeHeaderClass()
85
    {
86 1
        $classes = ['widget-user-header'];
87
88 1
        if (isset($this->theme) && empty($this->cover)) {
89 1
            $classes[] = "bg-gradient-{$this->theme}";
90
        }
91
92 1
        if (! empty($this->headerClass)) {
93 1
            $classes[] = $this->headerClass;
94
        }
95
96 1
        return implode(' ', $classes);
97
    }
98
99
    /**
100
     * Make the profile header style.
101
     *
102
     * @return string
103
     */
104 1
    public function makeHeaderStyle()
105
    {
106 1
        $style = [];
107
108 1
        if (! empty($this->cover)) {
109 1
            $style[] = "background: url('{$this->cover}') center center";
110
        }
111
112 1
        return implode(';', $style);
113
    }
114
115
    /**
116
     * Make the profile footer class.
117
     *
118
     * @return string
119
     */
120 1
    public function makeFooterClass()
121
    {
122 1
        $classes = ['card-footer'];
123
124 1
        if (! empty($this->footerClass)) {
125 1
            $classes[] = $this->footerClass;
126
        }
127
128 1
        return implode(' ', $classes);
129
    }
130
131
    /**
132
     * Get the view / contents that represent the component.
133
     *
134
     * @return \Illuminate\View\View|string
135
     */
136 1
    public function render()
137
    {
138 1
        return view('adminlte::components.profile-widget');
139
    }
140
}
141