Tinymce   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 116
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 12
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 116
ccs 0
cts 57
cp 0
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A basicToolbar() 0 6 1
A simpleToolbar() 0 6 1
A setToolbar() 0 6 1
A getBaseUrl() 0 8 2
A setBaseUrl() 0 6 1
A getPlugins() 0 4 1
A setPlugins() 0 6 1
A getOptions() 0 4 1
A setOptions() 0 6 1
A toArray() 0 13 2
1
<?php
2
3
namespace Sco\Admin\Form\Elements;
4
5
/**
6
 * @see https://www.tinymce.com/
7
 */
8
class Tinymce extends NamedElement
9
{
10
    protected $type = 'tinymce';
11
12
    protected $size = 'basic';
13
14
    protected $options = [];
15
16
    protected $baseUrl;
17
18
    protected $plugins;
19
20
    public function basicToolbar()
21
    {
22
        $this->size = 'basic';
23
24
        return $this;
25
    }
26
27
    public function simpleToolbar()
28
    {
29
        $this->size = 'simple';
30
31
        return $this;
32
    }
33
34
    /**
35
     * @param array $toolbar
36
     *
37
     * @return Tinymce
38
     */
39
    public function setToolbar(array $toolbar)
40
    {
41
        $this->options['toolbar'] = $toolbar;
42
43
        return $this;
44
    }
45
46
    /**
47
     * @return mixed
48
     */
49
    public function getBaseUrl()
50
    {
51
        if ($this->baseUrl) {
52
            return $this->baseUrl;
53
        }
54
55
        return url('js/tinymce');
56
    }
57
58
    /**
59
     * @param mixed $baseUrl
60
     *
61
     * @return Tinymce
62
     */
63
    public function setBaseUrl($baseUrl)
64
    {
65
        $this->baseUrl = $baseUrl;
66
67
        return $this;
68
    }
69
70
    /**
71
     * @return mixed
72
     */
73
    public function getPlugins()
74
    {
75
        return $this->plugins;
76
    }
77
78
    /**
79
     * @param mixed $plugins
80
     *
81
     * @return Tinymce
82
     */
83
    public function setPlugins($plugins)
84
    {
85
        $this->plugins = $plugins;
86
87
        return $this;
88
    }
89
90
    /**
91
     * @return mixed
92
     */
93
    public function getOptions()
94
    {
95
        return $this->options;
96
    }
97
98
    /**
99
     * @param mixed $options
100
     *
101
     * @return Tinymce
102
     */
103
    public function setOptions($options)
104
    {
105
        $this->options = $options;
0 ignored issues
show
Documentation Bug introduced by
It seems like $options of type * is incompatible with the declared type array of property $options.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
106
107
        return $this;
108
    }
109
110
    public function toArray()
111
    {
112
        $data = [
113
            'size'    => $this->size,
114
            'baseUrl' => $this->getBaseUrl(),
115
            'options' => $this->getOptions(),
116
        ];
117
        if (($plugins = $this->getPlugins())) {
118
            $data['plugins'] = $plugins;
119
        }
120
121
        return parent::toArray() + $data;
122
    }
123
}
124