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

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