ElSwitch::getWidth()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Sco\Admin\Form\Elements;
4
5
/**
6
 * Class ElSwitch
7
 *
8
 * @package Sco\Admin\Form\Elements
9
 * @see http://element.eleme.io/#/en-US/component/switch
10
 */
11
class ElSwitch extends NamedElement
12
{
13
    protected $type = 'elswitch';
14
15
    /**
16
     * Display Texts
17
     *
18
     * @var array
19
     */
20
    protected $texts = ['ON', 'OFF'];
21
22
    /**
23
     * Switch values.
24
     *
25
     * @var array
26
     */
27
    protected $values = ['1', '0'];
28
29
    /**
30
     * Background colors of display text.
31
     *
32
     * @var array
33
     */
34
    protected $colors = [];
35
36
    /**
37
     * class name of the icon displayed.
38
     *
39
     * @var array
40
     */
41
    protected $iconClasses = [];
42
43
    /**
44
     * width of Switch.
45
     *
46
     * @var int
47
     */
48
    protected $width = 40;
49
50
    /**
51
     * @return int
52
     */
53
    public function getWidth()
54
    {
55
        return $this->width;
56
    }
57
58
    /**
59
     * @param int $value
60
     * @return $this
61
     */
62
    public function setWidth(int $value)
63
    {
64
        $this->width = $value;
65
66
        return $this;
67
    }
68
69
    /**
70
     * @return array
71
     */
72
    public function getValues()
73
    {
74
        return $this->values;
75
    }
76
77
    /**
78
     * @param string|int $active
79
     * @param string|int $inactive
80
     *
81
     * @return ElSwitch
82
     */
83
    public function setValues($active, $inactive)
84
    {
85
        $this->values = [$active, $inactive];
86
87
        return $this;
88
    }
89
90
    /**
91
     * @return array
92
     */
93
    public function getTexts()
94
    {
95
        return $this->texts;
96
    }
97
98
    /**
99
     * @param string $active
100
     * @param string $inactive
101
     *
102
     * @return ElSwitch
103
     */
104
    public function setTexts(string $active, string $inactive)
105
    {
106
        $this->texts = [$active, $inactive];
107
108
        return $this;
109
    }
110
111
    /**
112
     * @return array
113
     */
114
    public function getColors()
115
    {
116
        return $this->colors;
117
    }
118
119
    /**
120
     * @param string $active
121
     * @param string $inactive
122
     *
123
     * @return ElSwitch
124
     */
125
    public function setColors(string $active, string $inactive)
126
    {
127
        $this->colors = [$active, $inactive];
128
129
        return $this;
130
    }
131
132
    /**
133
     * @return array
134
     */
135
    public function getIconClasses()
136
    {
137
        return $this->iconClasses;
138
    }
139
140
    /**
141
     * @param string $active
142
     * @param string $inactive
143
     *
144
     * @return $this
145
     */
146
    public function setIconClasses(string $active, string $inactive)
147
    {
148
        $this->iconClasses = [$active, $inactive];
149
150
        return $this;
151
    }
152
153
    public function toArray()
154
    {
155
        return parent::toArray() + [
156
                'texts'       => $this->getTexts(),
157
                'values'      => $this->getValues(),
158
                'colors'      => $this->getColors(),
159
                'iconClasses' => $this->getIconClasses(),
160
                'width'       => $this->getWidth(),
161
            ];
162
    }
163
}
164