PluginProbe
The Innovative Form Builder – IvyForms / 0.4
The Innovative Form Builder – IvyForms v0.4
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / ValueObjects / Field / FieldGeneralSettings.php

FieldGeneralSettings.php in The Innovative Form Builder – IvyForms 0.4, at backend/src/ValueObjects/Field/FieldGeneralSettings.php

419 lines 8.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * @copyright © TMS-Plugins. All rights reserved.
5 * @licence See LICENCE.md for license details.
6 */
7
8 namespace IvyForms\ValueObjects\Field;
9
10 // phpcs:disable PSR1.Files.SideEffects
11 if (!defined('ABSPATH')) {
12 exit; // Exit if accessed directly
13 }
14
15
16 use IvyForms\Common\Exceptions\ValidationException;
17
18 /**
19 * Class FieldGeneralSettings
20 *
21 * @SuppressWarnings(PHPMD)
22 * Encapsulates general settings for a field.
23 */
24 final class FieldGeneralSettings
25 {
26 /**
27 * @var string
28 */
29 private string $label;
30 /**
31 * @var bool
32 */
33 private bool $required;
34 /**
35 * @var string
36 */
37 private string $placeholder;
38 /**
39 * @var bool
40 */
41 private bool $hideLabel;
42 /**
43 * @var bool
44 */
45 private bool $readOnly;
46 /**
47 * @var string
48 */
49 private string $description;
50 /**
51 * @var string
52 */
53 private string $requiredMessage;
54 /**
55 * @var string
56 */
57 private string $cssClasses;
58 /**
59 * @var bool
60 */
61 private bool $shuffleOptions;
62 /**
63 * @var bool
64 */
65 private bool $showValues;
66 /**
67 * @var bool
68 */
69 private bool $enableSearch;
70 /**
71 * @var bool
72 */
73 private bool $visible;
74 /**
75 * @var string
76 */
77 private string $phoneFormat;
78 /**
79 * @var bool
80 */
81 private bool $phoneAutoDetect;
82 /**
83 * @var float
84 */
85 public float $minValue;
86 /**
87 * @var float
88 */
89 public float $maxValue;
90 /**
91 * @var float Step increment for number fields
92 */
93 public float $step;
94 /**
95 * @var string Number format key
96 */
97 public string $numberFormat;
98
99 /**
100 * Public constructor
101 *
102 * @param string $label
103 * @param bool $required
104 * @param string $placeholder
105 * @param bool $hideLabel
106 * @param bool $readOnly
107 * @param string $description
108 * @param string $requiredMessage
109 * @param string $cssClasses
110 * @param bool $shuffleOptions
111 * @param bool $showValues
112 * @param bool $enableSearch
113 * @param string $phoneFormat
114 * @param bool $phoneAutoDetect
115 * @param float $minValue
116 * @param float $maxValue
117 * @param float $step
118 * @param string $numberFormat
119 * @param bool $visible
120 */
121 /**
122 * @SuppressWarnings("ExcessiveParameterList")
123 * @SuppressWarnings("BooleanArgumentFlag")
124 */
125 public function __construct(
126 string $label,
127 bool $required,
128 string $placeholder,
129 bool $hideLabel,
130 bool $readOnly,
131 string $description,
132 string $requiredMessage,
133 string $cssClasses,
134 bool $shuffleOptions,
135 bool $showValues,
136 bool $enableSearch,
137 string $phoneFormat,
138 bool $phoneAutoDetect,
139 float $minValue,
140 float $maxValue,
141 float $step,
142 string $numberFormat,
143 bool $visible = true
144 ) {
145 $this->label = $label;
146 $this->required = $required;
147 $this->placeholder = $placeholder;
148 $this->hideLabel = $hideLabel;
149 $this->readOnly = $readOnly;
150 $this->description = $description;
151 $this->requiredMessage = $requiredMessage;
152 $this->cssClasses = $cssClasses;
153 $this->shuffleOptions = $shuffleOptions;
154 $this->showValues = $showValues;
155 $this->enableSearch = $enableSearch;
156 $this->phoneFormat = $phoneFormat;
157 $this->phoneAutoDetect = $phoneAutoDetect;
158 $this->minValue = $minValue;
159 $this->maxValue = $maxValue;
160 $this->step = $step;
161 $this->numberFormat = $numberFormat;
162 $this->visible = $visible;
163 }
164
165 /**
166 * Get the label.
167 * @return string
168 */
169 public function getLabel(): string
170 {
171 return $this->label;
172 }
173
174 /**
175 * Get the placeholder.
176 * @return string
177 */
178 public function getPlaceholder(): string
179 {
180 return $this->placeholder;
181 }
182
183 /**
184 * Get the description.
185 * @return string
186 */
187 public function getDescription(): string
188 {
189 return $this->description;
190 }
191
192 /**
193 * Get the required message.
194 * @return string
195 */
196 public function getRequiredMessage(): string
197 {
198 return $this->requiredMessage;
199 }
200
201 /**
202 * Get the CSS classes.
203 * @return string
204 */
205 public function getCssClasses(): string
206 {
207 return $this->cssClasses;
208 }
209
210 /**
211 * Get hideLabel.
212 * @return bool
213 */
214 public function isHideLabel(): bool
215 {
216 return $this->hideLabel;
217 }
218
219 /**
220 * Get readOnly.
221 * @return bool
222 */
223 public function isReadOnly(): bool
224 {
225 return $this->readOnly;
226 }
227
228 /**
229 * Get required.
230 * @return bool
231 */
232 public function isRequired(): bool
233 {
234 return $this->required;
235 }
236
237 /**
238 * Get shuffleOptions.
239 * @return bool
240 */
241 public function isShuffleOptions(): bool
242 {
243 return $this->shuffleOptions;
244 }
245
246 /**
247 * Get showValues.
248 * @return bool
249 */
250 public function isShowValues(): bool
251 {
252 return $this->showValues;
253 }
254
255 /**
256 * Get enableSearch.
257 * @return bool
258 */
259 public function isEnableSearch(): bool
260 {
261 return $this->enableSearch;
262 }
263
264 /**
265 * Get visible.
266 * @return bool
267 */
268 public function isVisible(): bool
269 {
270 return $this->visible;
271 }
272
273 /**
274 * Get the phone format.
275 *
276 * @return string
277 */
278 public function getPhoneFormat(): string
279 {
280 return $this->phoneFormat;
281 }
282
283 /**
284 * Set the phone format.
285 *
286 * @param string $format
287 */
288 public function setPhoneFormat(string $format): void
289 {
290 $this->phoneFormat = $format;
291 }
292
293 /**
294 * Get the phone auto-detect setting.
295 *
296 * @return bool
297 */
298 public function isPhoneAutoDetect(): bool
299 {
300 return $this->phoneAutoDetect;
301 }
302
303 /**
304 * Set the phone auto-detect setting.
305 *
306 * @param bool|null $val
307 */
308 public function setPhoneAutoDetect(?bool $val): void
309 {
310 $this->phoneAutoDetect = (bool)$val;
311 }
312 /**
313 * Get the minimum value.
314 *
315 * @return float
316 */
317 public function getMinValue(): float
318 {
319 return $this->minValue;
320 }
321
322 /**
323 * Set the minimum value.
324 *
325 * @param float $minValue
326 */
327 public function setMinValue(float $minValue): void
328 {
329 $this->minValue = $minValue;
330 }
331
332 /**
333 * Get the maximum value.
334 *
335 * @return float
336 */
337 public function getMaxValue(): float
338 {
339 return $this->maxValue;
340 }
341
342 /**
343 * Set the maximum value.
344 *
345 * @param float $maxValue
346 */
347 public function setMaxValue(float $maxValue): void
348 {
349 $this->maxValue = $maxValue;
350 }
351
352 /**
353 * Get the step value.
354 *
355 * @return float
356 */
357 public function getStep(): float
358 {
359 return $this->step;
360 }
361
362 /**
363 * Set the step value.
364 *
365 * @param float $step
366 */
367 public function setStep(float $step): void
368 {
369 $this->step = $step;
370 }
371
372 /**
373 * Get the number format.
374 *
375 * @return string
376 */
377 public function getNumberFormat(): string
378 {
379 return $this->numberFormat;
380 }
381
382 /**
383 * Set the number format.
384 *
385 * @param string $numberFormat
386 */
387 public function setNumberFormat(string $numberFormat): void
388 {
389 $this->numberFormat = $numberFormat;
390 }
391
392 /**
393 * @return array<string, bool|float|string>
394 */
395 public function toArray(): array
396 {
397 return [
398 'label' => $this->getLabel(),
399 'required' => $this->isRequired(),
400 'placeholder' => $this->getPlaceholder(),
401 'hideLabel' => $this->isHideLabel(),
402 'readOnly' => $this->isReadOnly(),
403 'description' => $this->getDescription(),
404 'requiredMessage' => $this->getRequiredMessage(),
405 'cssClasses' => $this->getCssClasses(),
406 'shuffleOptions' => $this->isShuffleOptions(),
407 'showValues' => $this->isShowValues(),
408 'enableSearch' => $this->isEnableSearch(),
409 'phoneFormat' => $this->getPhoneFormat(),
410 'phoneAutoDetect' => $this->isPhoneAutoDetect(),
411 'minValue' => $this->getMinValue(),
412 'maxValue' => $this->getMaxValue(),
413 'step' => $this->getStep(),
414 'numberFormat' => $this->getNumberFormat(),
415 'visible' => $this->isVisible(),
416 ];
417 }
418 }
419