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

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