Passed
Pull Request — master (#856)
by Florian
03:57
created

InputFile::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 9
dl 0
loc 12
ccs 5
cts 5
cp 1
crap 1
rs 10
c 1
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\Components;
4
5
class InputFile extends InputGroupComponent
6
{
7
    /**
8
     * The placeholder for the input file box.
9
     *
10
     * @var string
11
     */
12
    public $placeholder;
13
14
    /**
15
     * A legend for replace the default 'Browse' text.
16
     *
17
     * @var string
18
     */
19
    public $legend;
20
21
    /**
22
     * Create a new component instance.
23
     * Note this component requires the 'bs-custom-input-file' plugin.
24
     *
25
     * @return void
26
     */
27 2
    public function __construct(
28
        $name, $label = null, $size = null, $labelClass = null,
29
        $topClass = null, $inputGroupClass = null, $disableFeedback = null,
30
        $placeholder = '', $legend = null
31
    ) {
32 2
        parent::__construct(
33 2
            $name, $label, $size, $labelClass, $topClass,
34
            $inputGroupClass, $disableFeedback
35
        );
36
37 2
        $this->legend = $legend;
38 2
        $this->placeholder = $placeholder;
39 2
    }
40
41
    /**
42
     * Make the class attribute for the input group item.
43
     *
44
     * @param string $invalid
45
     * @return string
46
     */
47 1
    public function makeItemClass($invalid = null)
48
    {
49 1
        $classes = ['custom-file-input'];
50
51 1
        if (! empty($invalid) && ! isset($this->disableFeedback)) {
52 1
            $classes[] = 'is-invalid';
53
        }
54
55 1
        return implode(' ', $classes);
56
    }
57
58
    /**
59
     * Get the view / contents that represent the component.
60
     *
61
     * @return \Illuminate\View\View|string
62
     */
63 1
    public function render()
64
    {
65 1
        return view('adminlte::components.input-file');
66
    }
67
}
68