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

InputSwitch::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 1
eloc 1
c 2
b 1
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace JeroenNoten\LaravelAdminLte\Components;
4
5
class InputSwitch extends InputGroupComponent
6
{
7
    /**
8
     * The Bootstrap Switch 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
     * Create a new component instance.
18
     * Note this component requires the 'Bootstrap Switch' plugin.
19
     *
20
     * @return void
21
     */
22 2
    public function __construct(
23
        $name, $label = null, $size = null, $labelClass = null,
24
        $topClass = null, $disableFeedback = null, $config = []
25
    ) {
26 2
        parent::__construct(
27 2
            $name, $label, $size, $labelClass, $topClass, $disableFeedback
28
        );
29
30 2
        $this->config = is_array($config) ? $config : [];
31 2
    }
32
33
    /**
34
     * Make the class attribute for the input group item.
35
     *
36
     * @param string $invalid
37
     * @return string
38
     */
39 1
    public function makeItemClass($invalid)
40
    {
41 1
        $classes = [];
42
43 1
        if (! empty($invalid) && ! isset($this->disableFeedback)) {
44 1
            $classes[] = 'is-invalid';
45
        }
46
47 1
        return implode(' ', $classes);
48
    }
49
50
    /**
51
     * Get the view / contents that represent the component.
52
     *
53
     * @return \Illuminate\View\View|string
54
     */
55 1
    public function render()
56
    {
57 1
        return view('adminlte::components.input-switch');
58
    }
59
}
60