Select   A
last analyzed

Complexity

Total Complexity 17

Size/Duplication

Total Lines 220
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 17
lcom 1
cbo 0
dl 0
loc 220
rs 10
c 0
b 0
f 0

16 Methods

Rating   Name   Duplication   Size   Complexity  
A select() 0 6 1
A selectBlurable() 0 6 1
A selectClassName() 0 6 1
A selectAddClassName() 0 9 2
A selectInfo() 0 6 1
A selectItems() 0 6 1
A selectItemsRow() 0 6 1
A selectItemsColumn() 0 6 1
A selectItemsCell() 0 6 1
A selectSelector() 0 6 1
A selectStyle() 0 6 1
A selectStyleApi() 0 6 1
A selectStyleSingle() 0 6 1
A selectStyleMulti() 0 6 1
A selectStyleOS() 0 6 1
A selectStyleMultiShift() 0 6 1
1
<?php
2
3
namespace Yajra\DataTables\Html\Options\Plugins;
4
5
use Yajra\DataTables\Html\Builder;
6
7
/**
8
 * DataTables - Select plugin option builder.
9
 *
10
 * @see https://datatables.net/extensions/select
11
 * @see https://datatables.net/reference/option/select
12
 */
13
trait Select
14
{
15
    /**
16
     * Set select option value.
17
     *
18
     * @param bool|array $value
19
     * @return $this
20
     * @see https://datatables.net/reference/option/select
21
     */
22
    public function select($value = true)
23
    {
24
        $this->attributes['select'] = $value;
0 ignored issues
show
Bug introduced by
The property attributes does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
25
26
        return $this;
27
    }
28
29
    /**
30
     * Set select blurable option value.
31
     *
32
     * @param bool $value
33
     * @return $this
34
     * @see https://datatables.net/reference/option/select.blurable
35
     */
36
    public function selectBlurable(bool $value = true)
37
    {
38
        $this->attributes['select']['blurable'] = $value;
39
40
        return $this;
41
    }
42
43
    /**
44
     * Set select className option value.
45
     *
46
     * @param string $value
47
     * @return $this
48
     * @see https://datatables.net/reference/option/select.className
49
     */
50
    public function selectClassName($value = 'selected')
51
    {
52
        $this->attributes['select']['className'] = $value;
53
54
        return $this;
55
    }
56
57
    /**
58
     * Append a class name to className option value.
59
     *
60
     * @param string $class
61
     * @return $this
62
     */
63
    public function selectAddClassName($class)
64
    {
65
        if (! isset($this->attributes['select']['className'])) {
66
            $this->attributes['select']['className'] = $class;
67
        } else {
68
            $this->attributes['select']['className'] .= " $class";
69
        }
70
        return $this;
71
    }
72
73
    /**
74
     * Set select info option value.
75
     *
76
     * @param bool $value
77
     * @return $this
78
     * @see https://datatables.net/reference/option/select.info
79
     */
80
    public function selectInfo(bool $value = true)
81
    {
82
        $this->attributes['select']['info'] = $value;
83
84
        return $this;
85
    }
86
87
    /**
88
     * Set select items option value.
89
     *
90
     * @param string $value
91
     * @return $this
92
     * @see https://datatables.net/reference/option/select.items
93
     */
94
    public function selectItems($value = 'row')
95
    {
96
        $this->attributes['select']['items'] = $value;
97
98
        return $this;
99
    }
100
101
    /**
102
     * Set select items option value to row.
103
     *
104
     * @return $this
105
     * @see https://datatables.net/reference/option/select.items
106
     */
107
    public function selectItemsRow()
108
    {
109
        $this->attributes['select']['items'] = Builder::SELECT_ITEMS_ROW;
110
111
        return $this;
112
    }
113
114
    /**
115
     * Set select items option value to column.
116
     *
117
     * @return $this
118
     * @see https://datatables.net/reference/option/select.items
119
     */
120
    public function selectItemsColumn()
121
    {
122
        $this->attributes['select']['items'] = Builder::SELECT_ITEMS_COLUMN;
123
124
        return $this;
125
    }
126
127
    /**
128
     * Set select items option value to cell.
129
     *
130
     * @return $this
131
     * @see https://datatables.net/reference/option/select.items
132
     */
133
    public function selectItemsCell()
134
    {
135
        $this->attributes['select']['items'] = Builder::SELECT_ITEMS_CELL;
136
137
        return $this;
138
    }
139
140
    /**
141
     * Set select selector option value.
142
     *
143
     * @param string $value
144
     * @return $this
145
     * @see https://datatables.net/reference/option/select.selector
146
     */
147
    public function selectSelector($value = 'td')
148
    {
149
        $this->attributes['select']['selector'] = $value;
150
151
        return $this;
152
    }
153
154
    /**
155
     * Set select style option value.
156
     *
157
     * @param string $value
158
     * @return $this
159
     * @see https://datatables.net/reference/option/select.style
160
     */
161
    public function selectStyle($value = 'os')
162
    {
163
        $this->attributes['select']['style'] = $value;
164
165
        return $this;
166
    }
167
168
    /**
169
     * Set select style option value to api.
170
     *
171
     * @return $this
172
     * @see https://datatables.net/reference/option/select.style
173
     */
174
    public function selectStyleApi()
175
    {
176
        $this->attributes['select']['style'] = Builder::SELECT_STYLE_API;
177
178
        return $this;
179
    }
180
181
    /**
182
     * Set select style option value to single.
183
     *
184
     * @return $this
185
     * @see https://datatables.net/reference/option/select.style
186
     */
187
    public function selectStyleSingle()
188
    {
189
        $this->attributes['select']['style'] = Builder::SELECT_STYLE_SINGLE;
190
191
        return $this;
192
    }
193
194
    /**
195
     * Set select style option value to multi.
196
     *
197
     * @return $this
198
     * @see https://datatables.net/reference/option/select.style
199
     */
200
    public function selectStyleMulti()
201
    {
202
        $this->attributes['select']['style'] = Builder::SELECT_STYLE_MULTI;
203
204
        return $this;
205
    }
206
207
    /**
208
     * Set select style option value to os.
209
     *
210
     * @return $this
211
     * @see https://datatables.net/reference/option/select.style
212
     */
213
    public function selectStyleOS()
214
    {
215
        $this->attributes['select']['style'] = Builder::SELECT_STYLE_OS;
216
217
        return $this;
218
    }
219
220
    /**
221
     * Set select style option value to multi+shift.
222
     *
223
     * @return $this
224
     * @see https://datatables.net/reference/option/select.style
225
     */
226
    public function selectStyleMultiShift()
227
    {
228
        $this->attributes['select']['style'] = Builder::SELECT_STYLE_MULTI_SHIFT;
229
230
        return $this;
231
    }
232
}
233