DateRange::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 12
dl 0
loc 14
ccs 8
cts 8
cp 1
crap 2
rs 10
c 0
b 0
f 0

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