Passed
Pull Request — master (#721)
by Florian
02:40
created

Alert::icon()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 5
eloc 6
c 2
b 1
f 0
nc 5
nop 0
dl 0
loc 8
ccs 0
cts 7
cp 0
crap 30
rs 9.6111
1
<?php
2
3
namespace JeroenNoten\LaravelAdminLte\Components;
4
5
use Illuminate\View\Component;
6
7
class Alert extends Component
8
{
9
    public $type;
10
    public $title;
11
    public $dismissable;
12
13
    public function __construct($type = 'info', $dismissable = false, $title = 'Alert')
14
    {
15
        $this->type = $type;
16
        $this->title = $title;
17
        $this->dismissable = $dismissable;
18
    }
19
20
    public function icon()
21
    {
22
        switch ($this->type) {
23
            case 'info': return 'info'; break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
24
            case 'warning': return 'exclamation-triangle'; break;
25
            case 'success': return 'check'; break;
26
            case 'danger': return 'ban'; break;
27
            default: return 'exclamation'; break;
28
        }
29
    }
30
31
    public function render()
32
    {
33
        return view('adminlte::components.alert');
34
    }
35
}
36