PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
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
← All changes | backend/src/ValueObjects/Field/FieldGeneralSettings.php +606 -0 0.6.1 → 1.5 View file →
@@ -1,0 +1,606 @@
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 bool Show grid marks on slider
93 + */
94 + public bool $showGrid;
95 + /**
96 + * @var string Number format key
97 + */
98 + public string $numberFormat;
99 + /**
100 + * Confirmation settings grouped in a dedicated value object.
101 + * @var ConfirmationGeneralSettings
102 + */
103 + private ConfirmationGeneralSettings $confirmationSettings;
104 + /**
105 + * Time settings grouped in a dedicated value object.
106 + * @var TimeFieldGeneralSettings
107 + */
108 + private TimeFieldGeneralSettings $timeSettings;
109 + /**
110 + * Date settings grouped in a dedicated value object.
111 + * @var DateFieldGeneralSettings
112 + */
113 + private DateFieldGeneralSettings $dateSettings;
114 + /**
115 + * Whether to show text labels alongside rating.
116 + * @var bool
117 + */
118 + private bool $showRatingText;
119 + /**
120 + * @var string HTML content for HTML field type
121 + */
122 + private string $htmlContent;
123 + /**
124 + * @var string Agreement text for GDPR field type
125 + */
126 + private string $agreementText;
127 + /**
128 + * @var bool
129 + */
130 + private bool $limitRange;
131 +
132 + /**
133 + * Public constructor
134 + *
135 + * @param string $label
136 + * @param bool $required
137 + * @param string $placeholder
138 + * @param bool $hideLabel
139 + * @param bool $readOnly
140 + * @param string $description
141 + * @param string $requiredMessage
142 + * @param string $cssClasses
143 + * @param bool $shuffleOptions
144 + * @param bool $showValues
145 + * @param bool $enableSearch
146 + * @param string $phoneFormat
147 + * @param bool $phoneAutoDetect
148 + * @param float|null $minValue
149 + * @param float|null $maxValue
150 + * @param float $step
151 + * @param bool $showGrid
152 + * @param string $numberFormat
153 + * @param ConfirmationGeneralSettings $confirmationSettings
154 + * @param TimeFieldGeneralSettings $timeSettings
155 + * @param DateFieldGeneralSettings $dateSettings
156 + * @param bool $visible
157 + * @param bool $showRatingText
158 + * @param string $htmlContent
159 + * @param bool $limitRange
160 + */
161 + /**
162 + * @SuppressWarnings("ExcessiveParameterList")
163 + * @SuppressWarnings("BooleanArgumentFlag")
164 + */
165 + public function __construct(
166 + string $label,
167 + bool $required,
168 + string $placeholder,
169 + bool $hideLabel,
170 + bool $readOnly,
171 + string $description,
172 + string $requiredMessage,
173 + string $cssClasses,
174 + bool $shuffleOptions,
175 + bool $showValues,
176 + bool $enableSearch,
177 + string $phoneFormat,
178 + bool $phoneAutoDetect,
179 + ?float $minValue,
180 + ?float $maxValue,
181 + float $step,
182 + bool $showGrid,
183 + string $numberFormat,
184 + ConfirmationGeneralSettings $confirmationSettings,
185 + TimeFieldGeneralSettings $timeSettings,
186 + DateFieldGeneralSettings $dateSettings,
187 + bool $showRatingText,
188 + bool $visible = true,
189 + string $htmlContent = '',
190 + string $agreementText = '',
191 + bool $limitRange = false
192 + ) {
193 + $this->label = $label;
194 + $this->required = $required;
195 + $this->placeholder = $placeholder;
196 + $this->hideLabel = $hideLabel;
197 + $this->readOnly = $readOnly;
198 + $this->description = $description;
199 + $this->requiredMessage = $requiredMessage;
200 + $this->cssClasses = $cssClasses;
201 + $this->shuffleOptions = $shuffleOptions;
202 + $this->showValues = $showValues;
203 + $this->enableSearch = $enableSearch;
204 + $this->phoneFormat = $phoneFormat;
205 + $this->phoneAutoDetect = $phoneAutoDetect;
206 + $this->minValue = $minValue;
207 + $this->maxValue = $maxValue;
208 + $this->step = $step;
209 + $this->showGrid = $showGrid;
210 + $this->numberFormat = $numberFormat;
211 + $this->visible = $visible;
212 + $this->confirmationSettings = $confirmationSettings;
213 + $this->timeSettings = $timeSettings;
214 + $this->dateSettings = $dateSettings;
215 + $this->htmlContent = $htmlContent;
216 + $this->showRatingText = $showRatingText;
217 + $this->agreementText = $agreementText;
218 + $this->limitRange = $limitRange;
219 + }
220 +
221 + /**
222 + * Get the label.
223 + * @return string
224 + */
225 + public function getLabel(): string
226 + {
227 + return $this->label;
228 + }
229 +
230 + /**
231 + * Get the placeholder.
232 + * @return string
233 + */
234 + public function getPlaceholder(): string
235 + {
236 + return $this->placeholder;
237 + }
238 +
239 + /**
240 + * Get the description.
241 + * @return string
242 + */
243 + public function getDescription(): string
244 + {
245 + return $this->description;
246 + }
247 +
248 + /**
249 + * Get the required message.
250 + * @return string
251 + */
252 + public function getRequiredMessage(): string
253 + {
254 + return $this->requiredMessage;
255 + }
256 +
257 + /**
258 + * Get the CSS classes.
259 + * @return string
260 + */
261 + public function getCssClasses(): string
262 + {
263 + return $this->cssClasses;
264 + }
265 +
266 + /**
267 + * Get hideLabel.
268 + * @return bool
269 + */
270 + public function isHideLabel(): bool
271 + {
272 + return $this->hideLabel;
273 + }
274 +
275 + /**
276 + * Get readOnly.
277 + * @return bool
278 + */
279 + public function isReadOnly(): bool
280 + {
281 + return $this->readOnly;
282 + }
283 +
284 + /**
285 + * Get required.
286 + * @return bool
287 + */
288 + public function isRequired(): bool
289 + {
290 + return $this->required;
291 + }
292 +
293 + /**
294 + * Get shuffleOptions.
295 + * @return bool
296 + */
297 + public function isShuffleOptions(): bool
298 + {
299 + return $this->shuffleOptions;
300 + }
301 +
302 + /**
303 + * Get showValues.
304 + * @return bool
305 + */
306 + public function isShowValues(): bool
307 + {
308 + return $this->showValues;
309 + }
310 +
311 + /**
312 + * Get enableSearch.
313 + * @return bool
314 + */
315 + public function isEnableSearch(): bool
316 + {
317 + return $this->enableSearch;
318 + }
319 +
320 + /**
321 + * Get visible.
322 + * @return bool
323 + */
324 + public function isVisible(): bool
325 + {
326 + return $this->visible;
327 + }
328 +
329 + /**
330 + * Accessor for confirmation settings value object.
331 + * @return ConfirmationGeneralSettings
332 + */
333 + public function getConfirmationSettings(): ConfirmationGeneralSettings
334 + {
335 + return $this->confirmationSettings;
336 + }
337 +
338 + /**
339 + * Accessor for time settings value object.
340 + * @return TimeFieldGeneralSettings
341 + */
342 + public function getTimeSettings(): TimeFieldGeneralSettings
343 + {
344 + return $this->timeSettings;
345 + }
346 +
347 + /**
348 + * Accessor for date settings value object.
349 + * @return DateFieldGeneralSettings
350 + */
351 + public function getDateSettings(): DateFieldGeneralSettings
352 + {
353 + return $this->dateSettings;
354 + }
355 +
356 + /**
357 + * Get the phone format.
358 + *
359 + * @return string
360 + */
361 + public function getPhoneFormat(): string
362 + {
363 + return $this->phoneFormat;
364 + }
365 +
366 + /**
367 + * Set the phone format.
368 + *
369 + * @param string $format
370 + */
371 + public function setPhoneFormat(string $format): void
372 + {
373 + $this->phoneFormat = $format;
374 + }
375 +
376 + /**
377 + * Get the phone auto-detect setting.
378 + *
379 + * @return bool
380 + */
381 + public function isPhoneAutoDetect(): bool
382 + {
383 + return $this->phoneAutoDetect;
384 + }
385 +
386 + /**
387 + * Set the phone auto-detect setting.
388 + *
389 + * @param bool|null $val
390 + */
391 + public function setPhoneAutoDetect(?bool $val): void
392 + {
393 + $this->phoneAutoDetect = (bool)$val;
394 + }
395 + /**
396 + * Get the minimum value.
397 + *
398 + * @return float|null
399 + */
400 + public function getMinValue(): ?float
401 + {
402 + return $this->minValue;
403 + }
404 +
405 + /**
406 + * Set the minimum value.
407 + *
408 + * @param float|null $minValue
409 + */
410 + public function setMinValue(?float $minValue): void
411 + {
412 + $this->minValue = $minValue;
413 + }
414 +
415 + /**
416 + * Get the maximum value.
417 + *
418 + * @return float|null
419 + */
420 + public function getMaxValue(): ?float
421 + {
422 + return $this->maxValue;
423 + }
424 +
425 + /**
426 + * Set the maximum value.
427 + *
428 + * @param float|null $maxValue
429 + */
430 + public function setMaxValue(?float $maxValue): void
431 + {
432 + $this->maxValue = $maxValue;
433 + }
434 +
435 + /**
436 + * Get the step value.
437 + *
438 + * @return float
439 + */
440 + public function getStep(): float
441 + {
442 + return $this->step;
443 + }
444 +
445 + /**
446 + * Set the step value.
447 + *
448 + * @param float $step
449 + */
450 + public function setStep(float $step): void
451 + {
452 + $this->step = $step;
453 + }
454 +
455 + /**
456 + * Get the show grid value.
457 + *
458 + * @return bool
459 + */
460 + public function getShowGrid(): bool
461 + {
462 + return $this->showGrid;
463 + }
464 +
465 + /**
466 + * Set the show grid value.
467 + *
468 + * @param bool $showGrid
469 + */
470 + public function setShowGrid(bool $showGrid): void
471 + {
472 + $this->showGrid = $showGrid;
473 + }
474 +
475 + /**
476 + * Get the number format.
477 + *
478 + * @return string
479 + */
480 + public function getNumberFormat(): string
481 + {
482 + return $this->numberFormat;
483 + }
484 +
485 + /**
486 + * Set the number format.
487 + *
488 + * @param string $numberFormat
489 + */
490 + public function setNumberFormat(string $numberFormat): void
491 + {
492 + $this->numberFormat = $numberFormat;
493 + }
494 +
495 + /**
496 + * Get the HTML content.
497 + * @return string
498 + */
499 + public function getHtmlContent(): string
500 + {
501 + return $this->htmlContent;
502 + }
503 +
504 + /**
505 + * Set the HTML content.
506 + *
507 + * @param string $htmlContent
508 + */
509 + public function setHtmlContent(string $htmlContent): void
510 + {
511 + $this->htmlContent = $htmlContent;
512 + }
513 +
514 + /**
515 + * Get showRatingText flag.
516 + * @return bool
517 + */
518 + public function isShowRatingText(): bool
519 + {
520 + return $this->showRatingText;
521 + }
522 +
523 + /**
524 + * Set showRatingText flag.
525 + *
526 + * @param bool|null $val
527 + */
528 + public function setShowRatingText(?bool $val): void
529 + {
530 + $this->showRatingText = (bool)$val;
531 + }
532 +
533 + /**
534 + * Get the agreement text.
535 + * @return string
536 + */
537 + public function getAgreementText(): string
538 + {
539 + return $this->agreementText;
540 + }
541 +
542 + /**
543 + * Set the agreement text.
544 + *
545 + * @param string $agreementText
546 + */
547 + public function setAgreementText(string $agreementText): void
548 + {
549 + $this->agreementText = $agreementText;
550 + }
551 +
552 + /**
553 + * Get limitRange.
554 + * @return bool
555 + */
556 + public function isLimitRange(): bool
557 + {
558 + return $this->limitRange;
559 + }
560 +
561 + /**
562 + * Set limitRange.
563 + * @param bool $limitRange
564 + */
565 + public function setLimitRange(bool $limitRange): void
566 + {
567 + $this->limitRange = $limitRange;
568 + }
569 +
570 + /**
571 + * @return array<string, mixed>
572 + */
573 + public function toArray(): array
574 + {
575 + return array_merge(
576 + [
577 + 'label' => $this->getLabel(),
578 + 'required' => $this->isRequired(),
579 + 'placeholder' => $this->getPlaceholder(),
580 + 'hideLabel' => $this->isHideLabel(),
581 + 'readOnly' => $this->isReadOnly(),
582 + 'description' => $this->getDescription(),
583 + 'requiredMessage' => $this->getRequiredMessage(),
584 + 'cssClasses' => $this->getCssClasses(),
585 + 'shuffleOptions' => $this->isShuffleOptions(),
586 + 'showValues' => $this->isShowValues(),
587 + 'enableSearch' => $this->isEnableSearch(),
588 + 'phoneFormat' => $this->getPhoneFormat(),
589 + 'phoneAutoDetect' => $this->isPhoneAutoDetect(),
590 + 'minValue' => $this->getMinValue(),
591 + 'maxValue' => $this->getMaxValue(),
592 + 'step' => $this->getStep(),
593 + 'showGrid' => $this->getShowGrid(),
594 + 'numberFormat' => $this->getNumberFormat(),
595 + 'visible' => $this->isVisible(),
596 + 'showRatingText' => $this->isShowRatingText(),
597 + 'htmlContent' => $this->getHtmlContent(),
598 + 'agreementText' => $this->getAgreementText(),
599 + 'limitRange' => $this->isLimitRange(),
600 + ],
601 + $this->confirmationSettings->toArray(),
602 + $this->timeSettings->toArray(),
603 + $this->dateSettings->toArray()
604 + );
605 + }
606 +}