InputFile   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 13
dl 0
loc 61
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A render() 0 3 1
A makeItemClass() 0 9 2
1
<?php
2
3
namespace JeroenNoten\LaravelAdminLte\View\Components\Form;
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 the replacement of the default 'Browser' 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, $id = null, $label = null, $igroupSize = null, $labelClass = null,
29
        $fgroupClass = null, $igroupClass = null, $disableFeedback = null,
30
        $errorKey = null, $placeholder = '', $legend = null
31
    ) {
32 2
        parent::__construct(
33 2
            $name, $id, $label, $igroupSize, $labelClass, $fgroupClass,
34 2
            $igroupClass, $disableFeedback, $errorKey
35 2
        );
36
37 2
        $this->legend = $legend;
38 2
        $this->placeholder = $placeholder;
39
    }
40
41
    /**
42
     * Make the class attribute for the input group item. Note we overwrite
43
     * the method of the parent class.
44
     *
45
     * @return string
46
     */
47 1
    public function makeItemClass()
48
    {
49 1
        $classes = ['custom-file-input'];
50
51 1
        if ($this->isInvalid()) {
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.form.input-file');
66
    }
67
}
68