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

TextEditor   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
dl 0
loc 69
ccs 17
cts 17
cp 1
rs 10
c 1
b 0
f 0
wmc 9

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 2
A makeInputGroupClass() 0 17 6
A render() 0 3 1
1
<?php
2
3
namespace JeroenNoten\LaravelAdminLte\Components;
4
5
class TextEditor extends InputGroupComponent
6
{
7
    /**
8
     * The Summernote plugin configuration parameters. Array with key => value
9
     * pairs, where the key should be an existing configuration property of
10
     * the plugin.
11
     *
12
     * @var array
13
     */
14
    public $config;
15
16
    /**
17
     * Create a new component instance.
18
     * Note this component requires the 'Summernote' plugin.
19
     * TODO: the append/prepend addon slots are not supported.
20
     *
21
     * @return void
22
     */
23 2
    public function __construct(
24
        $name, $label = null, $size = null, $labelClass = null,
25
        $topClass = null, $inputGroupClass = null, $disableFeedback = null,
26
        $config = []
27
    ) {
28 2
        parent::__construct(
29 2
            $name, $label, $size, $labelClass, $topClass,
30
            $inputGroupClass, $disableFeedback
31
        );
32
33 2
        $this->config = is_array($config) ? $config : [];
34
35
        // Setup the default plugin width option.
36
37 2
        $this->config['width'] = $this->config['width'] ?? 'inherit';
38 2
    }
39
40
    /**
41
     * Make the class attribute for the "input-group" element. Note we overwrite
42
     * the method of the parent class.
43
     *
44
     * @param string $invalid
45
     * @return string
46
     */
47 1
    public function makeInputGroupClass($invalid = null)
48
    {
49 1
        $classes = ['input-group'];
50
51 1
        if (isset($this->size) && in_array($this->size, ['sm', 'lg'])) {
52 1
            $classes[] = "input-group-{$this->size}";
53
        }
54
55 1
        if (! empty($invalid) && ! isset($this->disableFeedback)) {
56 1
            $classes[] = 'adminlte-invalid-itegroup';
57
        }
58
59 1
        if (isset($this->inputGroupClass)) {
60 1
            $classes[] = $this->inputGroupClass;
61
        }
62
63 1
        return implode(' ', $classes);
64
    }
65
66
    /**
67
     * Get the view / contents that represent the component.
68
     *
69
     * @return \Illuminate\View\View|string
70
     */
71 1
    public function render()
72
    {
73 1
        return view('adminlte::components.text-editor');
74
    }
75
}
76