Passed
Pull Request — master (#721)
by Florian
14:00 queued 04:02
created

DateRange   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 24
c 2
b 1
f 0
dl 0
loc 40
rs 10
wmc 9

3 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 3 1
B initiator() 0 12 7
A __construct() 0 11 1
1
<?php
2
3
namespace JeroenNoten\LaravelAdminLte\Components;
4
5
use Illuminate\View\Component;
6
7
class DateRange extends Component
8
{
9
    public $topclass;
10
    public $inputclass;
11
    public $title;
12
    public $icon;
13
    public $id;
14
    public $init;
15
    public $callback;
16
17
    public function __construct(
18
        $id, $topclass = null, $title = 'Filter Range', $icon = 'far fa-calendar-alt',
19
        $init = 2, $callback = null, $inputclass = null
20
        ) {
21
        $this->id = $id;
22
        $this->topclass = $topclass;
23
        $this->inputclass = $inputclass;
24
        $this->title = $title;
25
        $this->icon = $icon;
26
        $this->init = $init;
27
        $this->callback = $callback;
28
    }
29
30
    public function initiator()
31
    {
32
        switch ($this->init) {
33
            case 0: $s = 'startDate: moment(), endDate: moment()'; break;
34
            case 1: $s = "startDate: moment().subtract(1, 'days'), endDate: moment().subtract(1, 'days')"; break;
35
            case 2: $s = "startDate: moment().subtract(6, 'days'), endDate: moment()"; break;
36
            case 3: $s = "startDate: moment().subtract(29, 'days'), endDate: moment()"; break;
37
            case 4: $s = "startDate: moment().startOf('month'), endDate: moment().endOf('month')"; break;
38
            case 5: $s = "startDate: moment().subtract(1, 'month').startOf('month'), endDate: moment().subtract(1, 'month').endOf('month')"; break;
39
        }
40
41
        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...
42
    }
43
44
    public function render()
45
    {
46
        return view('adminlte::date-range');
47
    }
48
}
49