PluginProbe
The Innovative Form Builder – IvyForms / 0.9
The Innovative Form Builder – IvyForms v0.9
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.9, at backend/src/ValueObjects/Field/FieldGeneralSettings.php

557 lines 12.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * @copyright © Melograno Venture Studio. 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 use IvyForms\Common\Exceptions\ValidationException;
16 use IvyForms\ValueObjects\Field\ConfirmationGeneralSettings;
17 use IvyForms\ValueObjects\Field\TimeFieldGeneralSettings;
18 use IvyForms\ValueObjects\Field\DateFieldGeneralSettings;
19
20 /**
21 * Class FieldGeneralSettings
22 *
23 * @SuppressWarnings(PHPMD)
24 * Encapsulates general settings for a field.
25 */
26 final class FieldGeneralSettings
27 {
28 /**
29 * @var string
30 */
31 private string $label;
32 /**
33 * @var bool
34 */
35 private bool $required;
36 /**
37 * @var string
38 */
39 private string $placeholder;
40 /**
41 * @var bool
42 */
43 private bool $hideLabel;
44 /**
45 * @var bool
46 */
47 private bool $readOnly;
48 /**
49 * @var string
50 */
51 private string $description;
52 /**
53 * @var string
54 */
55 private string $requiredMessage;
56 /**
57 * @var string
58 */
59 private string $cssClasses;
60 /**
61 * @var bool
62 */
63 private bool $shuffleOptions;
64 /**
65 * @var bool
66 */
67 private bool $showValues;
68 /**
69 * @var bool
70 */
71 private bool $enableSearch;
72 /**
73 * @var bool
74 */
75 private bool $visible;
76 /**
77 * @var string
78 */
79 private string $phoneFormat;
80 /**
81 * @var bool
82 */
83 private bool $phoneAutoDetect;
84 /**
85 * @var float|null
86 */
87 public ?float $minValue;
88 /**
89 * @var float|null
90 */
91 public ?float $maxValue;
92 /**
93 * @var float Step increment for number fields
94 */
95 public float $step;
96 /**
97 * @var string Number format key
98 */
99 public string $numberFormat;
100 /**
101 * Confirmation settings grouped in a dedicated value object.
102 * @var ConfirmationGeneralSettings
103 */
104 private ConfirmationGeneralSettings $confirmationSettings;
105 /**
106 * Time settings grouped in a dedicated value object.
107 * @var TimeFieldGeneralSettings
108 */
109 private TimeFieldGeneralSettings $timeSettings;
110 /**
111 * Date settings grouped in a dedicated value object.
112 * @var DateFieldGeneralSettings
113 */
114 private DateFieldGeneralSettings $dateSettings;
115 /**
116 * Whether to show text labels alongside rating.
117 * @var bool
118 */
119 private bool $showRatingText;
120 /**
121 * @var string HTML content for HTML field type
122 */
123 private string $htmlContent;
124 /**
125 * @var bool
126 */
127 private bool $limitRange;
128
129 /**
130 * Public constructor
131 *
132 * @param string $label
133 * @param bool $required
134 * @param string $placeholder
135 * @param bool $hideLabel
136 * @param bool $readOnly
137 * @param string $description
138 * @param string $requiredMessage
139 * @param string $cssClasses
140 * @param bool $shuffleOptions
141 * @param bool $showValues
142 * @param bool $enableSearch
143 * @param string $phoneFormat
144 * @param bool $phoneAutoDetect
145 * @param float|null $minValue
146 * @param float|null $maxValue
147 * @param float $step
148 * @param string $numberFormat
149 * @param TimeFieldGeneralSettings $timeSettings
150 * @param DateFieldGeneralSettings $dateSettings
151 * @param bool $visible
152 * @param bool $showRatingText
153 * @param string $htmlContent
154 * @param bool $limitRange
155 */
156 /**
157 * @SuppressWarnings("ExcessiveParameterList")
158 * @SuppressWarnings("BooleanArgumentFlag")
159 */
160 public function __construct(
161 string $label,
162 bool $required,
163 string $placeholder,
164 bool $hideLabel,
165 bool $readOnly,
166 string $description,
167 string $requiredMessage,
168 string $cssClasses,
169 bool $shuffleOptions,
170 bool $showValues,
171 bool $enableSearch,
172 string $phoneFormat,
173 bool $phoneAutoDetect,
174 ?float $minValue,
175 ?float $maxValue,
176 float $step,
177 string $numberFormat,
178 ConfirmationGeneralSettings $confirmationSettings,
179 TimeFieldGeneralSettings $timeSettings,
180 DateFieldGeneralSettings $dateSettings,
181 bool $showRatingText,
182 bool $visible = true,
183 string $htmlContent = '',
184 bool $limitRange = false
185 ) {
186 $this->label = $label;
187 $this->required = $required;
188 $this->placeholder = $placeholder;
189 $this->hideLabel = $hideLabel;
190 $this->readOnly = $readOnly;
191 $this->description = $description;
192 $this->requiredMessage = $requiredMessage;
193 $this->cssClasses = $cssClasses;
194 $this->shuffleOptions = $shuffleOptions;
195 $this->showValues = $showValues;
196 $this->enableSearch = $enableSearch;
197 $this->phoneFormat = $phoneFormat;
198 $this->phoneAutoDetect = $phoneAutoDetect;
199 $this->minValue = $minValue;
200 $this->maxValue = $maxValue;
201 $this->step = $step;
202 $this->numberFormat = $numberFormat;
203 $this->visible = $visible;
204 $this->confirmationSettings = $confirmationSettings;
205 $this->timeSettings = $timeSettings;
206 $this->dateSettings = $dateSettings;
207 $this->showRatingText = $showRatingText;
208 $this->htmlContent = $htmlContent;
209 $this->limitRange = $limitRange;
210 }
211
212 /**
213 * Get the label.
214 * @return string
215 */
216 public function getLabel(): string
217 {
218 return $this->label;
219 }
220
221 /**
222 * Get the placeholder.
223 * @return string
224 */
225 public function getPlaceholder(): string
226 {
227 return $this->placeholder;
228 }
229
230 /**
231 * Get the description.
232 * @return string
233 */
234 public function getDescription(): string
235 {
236 return $this->description;
237 }
238
239 /**
240 * Get the required message.
241 * @return string
242 */
243 public function getRequiredMessage(): string
244 {
245 return $this->requiredMessage;
246 }
247
248 /**
249 * Get the CSS classes.
250 * @return string
251 */
252 public function getCssClasses(): string
253 {
254 return $this->cssClasses;
255 }
256
257 /**
258 * Get hideLabel.
259 * @return bool
260 */
261 public function isHideLabel(): bool
262 {
263 return $this->hideLabel;
264 }
265
266 /**
267 * Get readOnly.
268 * @return bool
269 */
270 public function isReadOnly(): bool
271 {
272 return $this->readOnly;
273 }
274
275 /**
276 * Get required.
277 * @return bool
278 */
279 public function isRequired(): bool
280 {
281 return $this->required;
282 }
283
284 /**
285 * Get shuffleOptions.
286 * @return bool
287 */
288 public function isShuffleOptions(): bool
289 {
290 return $this->shuffleOptions;
291 }
292
293 /**
294 * Get showValues.
295 * @return bool
296 */
297 public function isShowValues(): bool
298 {
299 return $this->showValues;
300 }
301
302 /**
303 * Get enableSearch.
304 * @return bool
305 */
306 public function isEnableSearch(): bool
307 {
308 return $this->enableSearch;
309 }
310
311 /**
312 * Get visible.
313 * @return bool
314 */
315 public function isVisible(): bool
316 {
317 return $this->visible;
318 }
319
320 /**
321 * Accessor for confirmation settings value object.
322 * @return ConfirmationGeneralSettings
323 */
324 public function getConfirmationSettings(): ConfirmationGeneralSettings
325 {
326 return $this->confirmationSettings;
327 }
328
329 /**
330 * Accessor for time settings value object.
331 * @return TimeFieldGeneralSettings
332 */
333 public function getTimeSettings(): TimeFieldGeneralSettings
334 {
335 return $this->timeSettings;
336 }
337
338 /**
339 * Accessor for date settings value object.
340 * @return DateFieldGeneralSettings
341 */
342 public function getDateSettings(): DateFieldGeneralSettings
343 {
344 return $this->dateSettings;
345 }
346
347 /**
348 * Get the phone format.
349 *
350 * @return string
351 */
352 public function getPhoneFormat(): string
353 {
354 return $this->phoneFormat;
355 }
356
357 /**
358 * Set the phone format.
359 *
360 * @param string $format
361 */
362 public function setPhoneFormat(string $format): void
363 {
364 $this->phoneFormat = $format;
365 }
366
367 /**
368 * Get the phone auto-detect setting.
369 *
370 * @return bool
371 */
372 public function isPhoneAutoDetect(): bool
373 {
374 return $this->phoneAutoDetect;
375 }
376
377 /**
378 * Set the phone auto-detect setting.
379 *
380 * @param bool|null $val
381 */
382 public function setPhoneAutoDetect(?bool $val): void
383 {
384 $this->phoneAutoDetect = (bool)$val;
385 }
386 /**
387 * Get the minimum value.
388 *
389 * @return float|null
390 */
391 public function getMinValue(): ?float
392 {
393 return $this->minValue;
394 }
395
396 /**
397 * Set the minimum value.
398 *
399 * @param float|null $minValue
400 */
401 public function setMinValue(?float $minValue): void
402 {
403 $this->minValue = $minValue;
404 }
405
406 /**
407 * Get the maximum value.
408 *
409 * @return float|null
410 */
411 public function getMaxValue(): ?float
412 {
413 return $this->maxValue;
414 }
415
416 /**
417 * Set the maximum value.
418 *
419 * @param float|null $maxValue
420 */
421 public function setMaxValue(?float $maxValue): void
422 {
423 $this->maxValue = $maxValue;
424 }
425
426 /**
427 * Get the step value.
428 *
429 * @return float
430 */
431 public function getStep(): float
432 {
433 return $this->step;
434 }
435
436 /**
437 * Set the step value.
438 *
439 * @param float $step
440 */
441 public function setStep(float $step): void
442 {
443 $this->step = $step;
444 }
445
446 /**
447 * Get the number format.
448 *
449 * @return string
450 */
451 public function getNumberFormat(): string
452 {
453 return $this->numberFormat;
454 }
455
456 /**
457 * Set the number format.
458 *
459 * @param string $numberFormat
460 */
461 public function setNumberFormat(string $numberFormat): void
462 {
463 $this->numberFormat = $numberFormat;
464 }
465
466 /**
467 * Get showRatingText flag.
468 * @return bool
469 */
470 public function isShowRatingText(): bool
471 {
472 return $this->showRatingText;
473 }
474
475 /**
476 * Set showRatingText flag.
477 *
478 * @param bool|null $val
479 */
480 public function setShowRatingText(?bool $val): void
481 {
482 $this->showRatingText = (bool)$val;
483 }
484
485 /**
486 * Get the HTML content.
487 * @return string
488 */
489 public function getHtmlContent(): string
490 {
491 return $this->htmlContent;
492 }
493
494 /**
495 * Set the HTML content.
496 *
497 * @param string $htmlContent
498 */
499 public function setHtmlContent(string $htmlContent): void
500 {
501 $this->htmlContent = $htmlContent;
502 }
503
504 /**
505 * Get limitRange.
506 * @return bool
507 */
508 public function isLimitRange(): bool
509 {
510 return $this->limitRange;
511 }
512
513 /**
514 * Set limitRange.
515 * @param bool $limitRange
516 */
517 public function setLimitRange(bool $limitRange): void
518 {
519 $this->limitRange = $limitRange;
520 }
521
522 /**
523 * @return array<string, mixed>
524 */
525 public function toArray(): array
526 {
527 return array_merge(
528 [
529 'label' => $this->getLabel(),
530 'required' => $this->isRequired(),
531 'placeholder' => $this->getPlaceholder(),
532 'hideLabel' => $this->isHideLabel(),
533 'readOnly' => $this->isReadOnly(),
534 'description' => $this->getDescription(),
535 'requiredMessage' => $this->getRequiredMessage(),
536 'cssClasses' => $this->getCssClasses(),
537 'shuffleOptions' => $this->isShuffleOptions(),
538 'showValues' => $this->isShowValues(),
539 'enableSearch' => $this->isEnableSearch(),
540 'phoneFormat' => $this->getPhoneFormat(),
541 'phoneAutoDetect' => $this->isPhoneAutoDetect(),
542 'minValue' => $this->getMinValue(),
543 'maxValue' => $this->getMaxValue(),
544 'step' => $this->getStep(),
545 'numberFormat' => $this->getNumberFormat(),
546 'visible' => $this->isVisible(),
547 'showRatingText' => $this->isShowRatingText(),
548 'htmlContent' => $this->getHtmlContent(),
549 'limitRange' => $this->isLimitRange(),
550 ],
551 $this->confirmationSettings->toArray(),
552 $this->timeSettings->toArray(),
553 $this->dateSettings->toArray()
554 );
555 }
556 }
557