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

504 lines 11.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 // 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 /**
122 * Public constructor
123 *
124 * @param string $label
125 * @param bool $required
126 * @param string $placeholder
127 * @param bool $hideLabel
128 * @param bool $readOnly
129 * @param string $description
130 * @param string $requiredMessage
131 * @param string $cssClasses
132 * @param bool $shuffleOptions
133 * @param bool $showValues
134 * @param bool $enableSearch
135 * @param string $phoneFormat
136 * @param bool $phoneAutoDetect
137 * @param float|null $minValue
138 * @param float|null $maxValue
139 * @param float $step
140 * @param string $numberFormat
141 * @param TimeFieldGeneralSettings $timeSettings
142 * @param DateFieldGeneralSettings $dateSettings
143 * @param bool $visible
144 * @param bool $showRatingText
145 */
146 /**
147 * @SuppressWarnings("ExcessiveParameterList")
148 * @SuppressWarnings("BooleanArgumentFlag")
149 */
150 public function __construct(
151 string $label,
152 bool $required,
153 string $placeholder,
154 bool $hideLabel,
155 bool $readOnly,
156 string $description,
157 string $requiredMessage,
158 string $cssClasses,
159 bool $shuffleOptions,
160 bool $showValues,
161 bool $enableSearch,
162 string $phoneFormat,
163 bool $phoneAutoDetect,
164 ?float $minValue,
165 ?float $maxValue,
166 float $step,
167 string $numberFormat,
168 ConfirmationGeneralSettings $confirmationSettings,
169 TimeFieldGeneralSettings $timeSettings,
170 DateFieldGeneralSettings $dateSettings,
171 bool $showRatingText,
172 bool $visible = true
173 ) {
174 $this->label = $label;
175 $this->required = $required;
176 $this->placeholder = $placeholder;
177 $this->hideLabel = $hideLabel;
178 $this->readOnly = $readOnly;
179 $this->description = $description;
180 $this->requiredMessage = $requiredMessage;
181 $this->cssClasses = $cssClasses;
182 $this->shuffleOptions = $shuffleOptions;
183 $this->showValues = $showValues;
184 $this->enableSearch = $enableSearch;
185 $this->phoneFormat = $phoneFormat;
186 $this->phoneAutoDetect = $phoneAutoDetect;
187 $this->minValue = $minValue;
188 $this->maxValue = $maxValue;
189 $this->step = $step;
190 $this->numberFormat = $numberFormat;
191 $this->visible = $visible;
192 $this->confirmationSettings = $confirmationSettings;
193 $this->timeSettings = $timeSettings;
194 $this->dateSettings = $dateSettings;
195 $this->showRatingText = $showRatingText;
196 }
197
198 /**
199 * Get the label.
200 * @return string
201 */
202 public function getLabel(): string
203 {
204 return $this->label;
205 }
206
207 /**
208 * Get the placeholder.
209 * @return string
210 */
211 public function getPlaceholder(): string
212 {
213 return $this->placeholder;
214 }
215
216 /**
217 * Get the description.
218 * @return string
219 */
220 public function getDescription(): string
221 {
222 return $this->description;
223 }
224
225 /**
226 * Get the required message.
227 * @return string
228 */
229 public function getRequiredMessage(): string
230 {
231 return $this->requiredMessage;
232 }
233
234 /**
235 * Get the CSS classes.
236 * @return string
237 */
238 public function getCssClasses(): string
239 {
240 return $this->cssClasses;
241 }
242
243 /**
244 * Get hideLabel.
245 * @return bool
246 */
247 public function isHideLabel(): bool
248 {
249 return $this->hideLabel;
250 }
251
252 /**
253 * Get readOnly.
254 * @return bool
255 */
256 public function isReadOnly(): bool
257 {
258 return $this->readOnly;
259 }
260
261 /**
262 * Get required.
263 * @return bool
264 */
265 public function isRequired(): bool
266 {
267 return $this->required;
268 }
269
270 /**
271 * Get shuffleOptions.
272 * @return bool
273 */
274 public function isShuffleOptions(): bool
275 {
276 return $this->shuffleOptions;
277 }
278
279 /**
280 * Get showValues.
281 * @return bool
282 */
283 public function isShowValues(): bool
284 {
285 return $this->showValues;
286 }
287
288 /**
289 * Get enableSearch.
290 * @return bool
291 */
292 public function isEnableSearch(): bool
293 {
294 return $this->enableSearch;
295 }
296
297 /**
298 * Get visible.
299 * @return bool
300 */
301 public function isVisible(): bool
302 {
303 return $this->visible;
304 }
305
306 /**
307 * Accessor for confirmation settings value object.
308 * @return ConfirmationGeneralSettings
309 */
310 public function getConfirmationSettings(): ConfirmationGeneralSettings
311 {
312 return $this->confirmationSettings;
313 }
314
315 /**
316 * Accessor for time settings value object.
317 * @return TimeFieldGeneralSettings
318 */
319 public function getTimeSettings(): TimeFieldGeneralSettings
320 {
321 return $this->timeSettings;
322 }
323
324 /**
325 * Accessor for date settings value object.
326 * @return DateFieldGeneralSettings
327 */
328 public function getDateSettings(): DateFieldGeneralSettings
329 {
330 return $this->dateSettings;
331 }
332
333 /**
334 * Get the phone format.
335 *
336 * @return string
337 */
338 public function getPhoneFormat(): string
339 {
340 return $this->phoneFormat;
341 }
342
343 /**
344 * Set the phone format.
345 *
346 * @param string $format
347 */
348 public function setPhoneFormat(string $format): void
349 {
350 $this->phoneFormat = $format;
351 }
352
353 /**
354 * Get the phone auto-detect setting.
355 *
356 * @return bool
357 */
358 public function isPhoneAutoDetect(): bool
359 {
360 return $this->phoneAutoDetect;
361 }
362
363 /**
364 * Set the phone auto-detect setting.
365 *
366 * @param bool|null $val
367 */
368 public function setPhoneAutoDetect(?bool $val): void
369 {
370 $this->phoneAutoDetect = (bool)$val;
371 }
372 /**
373 * Get the minimum value.
374 *
375 * @return float|null
376 */
377 public function getMinValue(): ?float
378 {
379 return $this->minValue;
380 }
381
382 /**
383 * Set the minimum value.
384 *
385 * @param float|null $minValue
386 */
387 public function setMinValue(?float $minValue): void
388 {
389 $this->minValue = $minValue;
390 }
391
392 /**
393 * Get the maximum value.
394 *
395 * @return float|null
396 */
397 public function getMaxValue(): ?float
398 {
399 return $this->maxValue;
400 }
401
402 /**
403 * Set the maximum value.
404 *
405 * @param float|null $maxValue
406 */
407 public function setMaxValue(?float $maxValue): void
408 {
409 $this->maxValue = $maxValue;
410 }
411
412 /**
413 * Get the step value.
414 *
415 * @return float
416 */
417 public function getStep(): float
418 {
419 return $this->step;
420 }
421
422 /**
423 * Set the step value.
424 *
425 * @param float $step
426 */
427 public function setStep(float $step): void
428 {
429 $this->step = $step;
430 }
431
432 /**
433 * Get the number format.
434 *
435 * @return string
436 */
437 public function getNumberFormat(): string
438 {
439 return $this->numberFormat;
440 }
441
442 /**
443 * Set the number format.
444 *
445 * @param string $numberFormat
446 */
447 public function setNumberFormat(string $numberFormat): void
448 {
449 $this->numberFormat = $numberFormat;
450 }
451
452 /**
453 * Get showRatingText flag.
454 * @return bool
455 */
456 public function isShowRatingText(): bool
457 {
458 return $this->showRatingText;
459 }
460
461 /**
462 * Set showRatingText flag.
463 *
464 * @param bool|null $val
465 */
466 public function setShowRatingText(?bool $val): void
467 {
468 $this->showRatingText = (bool)$val;
469 }
470
471 /**
472 * @return array<string, mixed>
473 */
474 public function toArray(): array
475 {
476 return array_merge(
477 [
478 'label' => $this->getLabel(),
479 'required' => $this->isRequired(),
480 'placeholder' => $this->getPlaceholder(),
481 'hideLabel' => $this->isHideLabel(),
482 'readOnly' => $this->isReadOnly(),
483 'description' => $this->getDescription(),
484 'requiredMessage' => $this->getRequiredMessage(),
485 'cssClasses' => $this->getCssClasses(),
486 'shuffleOptions' => $this->isShuffleOptions(),
487 'showValues' => $this->isShowValues(),
488 'enableSearch' => $this->isEnableSearch(),
489 'phoneFormat' => $this->getPhoneFormat(),
490 'phoneAutoDetect' => $this->isPhoneAutoDetect(),
491 'minValue' => $this->getMinValue(),
492 'maxValue' => $this->getMaxValue(),
493 'step' => $this->getStep(),
494 'numberFormat' => $this->getNumberFormat(),
495 'visible' => $this->isVisible(),
496 'showRatingText' => $this->isShowRatingText(),
497 ],
498 $this->confirmationSettings->toArray(),
499 $this->timeSettings->toArray(),
500 $this->dateSettings->toArray()
501 );
502 }
503 }
504