Passed
Pull Request — master (#721)
by Florian
02:44
created

InputSwitch   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 10
c 2
b 1
f 0
dl 0
loc 53
ccs 12
cts 12
cp 1
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A makeItemClass() 0 9 3
A render() 0 3 1
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