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

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