Passed
Pull Request — master (#721)
by Florian
09:26
created

DateRange::initiator()   B

Complexity

Conditions 7
Paths 7

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 7
eloc 8
c 1
b 0
f 0
nc 7
nop 0
dl 0
loc 12
rs 8.8333
1
<?php
2
3
namespace JeroenNoten\LaravelAdminLte\Components;
4
5
use Illuminate\View\Component;
6
7
class DateRange extends Component
8
{
9
    public $topclass, $inputclass, $title, $icon, $id;
10
    public $init;
11
    public $callback;
12
13
    public function __construct(
14
        $id, $topclass = null, $title = 'Filter Range', $icon = 'far fa-calendar-alt',
15
        $init = 2, $callback = null, $inputclass = null
16
        )
17
    {
18
        $this->id = $id;
19
        $this->topclass = $topclass;
20
        $this->inputclass = $inputclass;
21
        $this->title = $title;
22
        $this->icon = $icon;
23
        $this->init = $init;
24
        $this->callback = $callback;
25
    }
26
27
    public function initiator()
28
    {
29
        switch($this->init)
30
        {
31
            case 0 : $s = "startDate: moment(), endDate: moment()"; break;
32
            case 1 : $s = "startDate: moment().subtract(1, 'days'), endDate: moment().subtract(1, 'days')"; break;
33
            case 2 : $s = "startDate: moment().subtract(6, 'days'), endDate: moment()"; break;
34
            case 3 : $s = "startDate: moment().subtract(29, 'days'), endDate: moment()"; break;
35
            case 4 : $s = "startDate: moment().startOf('month'), endDate: moment().endOf('month')"; break;
36
            case 5 : $s = "startDate: moment().subtract(1, 'month').startOf('month'), endDate: moment().subtract(1, 'month').endOf('month')"; break;
37
        }
38
        return $s;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $s does not seem to be defined for all execution paths leading up to this point.
Loading history...
39
    }
40
41
    public function render()
42
    {
43
        return view('adminlte::date-range');
44
    }
45
}