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

DateRange::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 8
dl 0
loc 11
ccs 5
cts 5
cp 1
crap 2
rs 10

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
class DateRange extends InputGroupComponent
6
{
7
    /**
8
     * The DateRangePicker plugin configuration parameters. Array with
9
     * key => value pairs, where the key should be an existing configuration
10
     * property of the plugin.
11
     *
12
     * @var array
13
     */
14
    public $config;
15
16
    /**
17
     * Enables a default set of ranges option. The string value, if any, will
18
     * be used as the initial date range. The available values are: 'Today',
19
     * 'Yesterday', 'Last 7 Days', 'Last 30 Days', 'This Month' or 'Last Month'.
20
     *
21
     * @var bool|string
22
     */
23
    public $enableDefaultRanges;
24
25
    /**
26
     * Create a new component instance.
27
     * Note this component requires the 'DateRangePicker' and 'Moment' plugins.
28
     *
29
     * @return void
30
     */
31 1
    public function __construct(
32
        $name, $label = null, $size = null, $labelClass = null,
33
        $topClass = null, $disableFeedback = null, $config = [],
34
        $enableDefaultRanges = null
35
    ) {
36 1
        parent::__construct(
37 1
            $name, $label, $size, $labelClass, $topClass, $disableFeedback
38
        );
39
40 1
        $this->config = is_array($config) ? $config : [];
41 1
        $this->enableDefaultRanges = $enableDefaultRanges;
42 1
    }
43
44
    /**
45
     * Get the view / contents that represent the component.
46
     *
47
     * @return \Illuminate\View\View|string
48
     */
49 1
    public function render()
50
    {
51 1
        return view('adminlte::components.date-range');
52
    }
53
}
54