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

FieldGeneralSettings.php in The Innovative Form Builder – IvyForms 0.5, at backend/src/ValueObjects/Field/FieldGeneralSettings.php

440 lines 9.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 © 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
19 /**
20 * Class FieldGeneralSettings
21 *
22 * @SuppressWarnings(PHPMD)
23 * Encapsulates general settings for a field.
24 */
25 final class FieldGeneralSettings
26 {
27 /**
28 * @var string
29 */
30 private string $label;
31 /**
32 * @var bool
33 */
34 private bool $required;
35 /**
36 * @var string
37 */
38 private string $placeholder;
39 /**
40 * @var bool
41 */
42 private bool $hideLabel;
43 /**
44 * @var bool
45 */
46 private bool $readOnly;
47 /**
48 * @var string
49 */
50 private string $description;
51 /**
52 * @var string
53 */
54 private string $requiredMessage;
55 /**
56 * @var string
57 */
58 private string $cssClasses;
59 /**
60 * @var bool
61 */
62 private bool $shuffleOptions;
63 /**
64 * @var bool
65 */
66 private bool $showValues;
67 /**
68 * @var bool
69 */
70 private bool $enableSearch;
71 /**
72 * @var bool
73 */
74 private bool $visible;
75 /**
76 * @var string
77 */
78 private string $phoneFormat;
79 /**
80 * @var bool
81 */
82 private bool $phoneAutoDetect;
83 /**
84 * @var float|null
85 */
86 public ?float $minValue;
87 /**
88 * @var float|null
89 */
90 public ?float $maxValue;
91 /**
92 * @var float Step increment for number fields
93 */
94 public float $step;
95 /**
96 * @var string Number format key
97 */
98 public string $numberFormat;
99 /**
100 * Time settings grouped in a dedicated value object.
101 * @var TimeFieldGeneralSettings
102 */
103 private TimeFieldGeneralSettings $timeSettings;
104
105 /**
106 * Public constructor
107 *
108 * @param string $label
109 * @param bool $required
110 * @param string $placeholder
111 * @param bool $hideLabel
112 * @param bool $readOnly
113 * @param string $description
114 * @param string $requiredMessage
115 * @param string $cssClasses
116 * @param bool $shuffleOptions
117 * @param bool $showValues
118 * @param bool $enableSearch
119 * @param string $phoneFormat
120 * @param bool $phoneAutoDetect
121 * @param float|null $minValue
122 * @param float|null $maxValue
123 * @param float $step
124 * @param string $numberFormat
125 * @param TimeFieldGeneralSettings $timeSettings
126 * @param bool $visible
127 */
128 /**
129 * @SuppressWarnings("ExcessiveParameterList")
130 * @SuppressWarnings("BooleanArgumentFlag")
131 */
132 public function __construct(
133 string $label,
134 bool $required,
135 string $placeholder,
136 bool $hideLabel,
137 bool $readOnly,
138 string $description,
139 string $requiredMessage,
140 string $cssClasses,
141 bool $shuffleOptions,
142 bool $showValues,
143 bool $enableSearch,
144 string $phoneFormat,
145 bool $phoneAutoDetect,
146 ?float $minValue,
147 ?float $maxValue,
148 float $step,
149 string $numberFormat,
150 TimeFieldGeneralSettings $timeSettings,
151 bool $visible = true
152 ) {
153 $this->label = $label;
154 $this->required = $required;
155 $this->placeholder = $placeholder;
156 $this->hideLabel = $hideLabel;
157 $this->readOnly = $readOnly;
158 $this->description = $description;
159 $this->requiredMessage = $requiredMessage;
160 $this->cssClasses = $cssClasses;
161 $this->shuffleOptions = $shuffleOptions;
162 $this->showValues = $showValues;
163 $this->enableSearch = $enableSearch;
164 $this->phoneFormat = $phoneFormat;
165 $this->phoneAutoDetect = $phoneAutoDetect;
166 $this->minValue = $minValue;
167 $this->maxValue = $maxValue;
168 $this->step = $step;
169 $this->numberFormat = $numberFormat;
170 $this->visible = $visible;
171 $this->timeSettings = $timeSettings;
172 }
173
174 /**
175 * Get the label.
176 * @return string
177 */
178 public function getLabel(): string
179 {
180 return $this->label;
181 }
182
183 /**
184 * Get the placeholder.
185 * @return string
186 */
187 public function getPlaceholder(): string
188 {
189 return $this->placeholder;
190 }
191
192 /**
193 * Get the description.
194 * @return string
195 */
196 public function getDescription(): string
197 {
198 return $this->description;
199 }
200
201 /**
202 * Get the required message.
203 * @return string
204 */
205 public function getRequiredMessage(): string
206 {
207 return $this->requiredMessage;
208 }
209
210 /**
211 * Get the CSS classes.
212 * @return string
213 */
214 public function getCssClasses(): string
215 {
216 return $this->cssClasses;
217 }
218
219 /**
220 * Get hideLabel.
221 * @return bool
222 */
223 public function isHideLabel(): bool
224 {
225 return $this->hideLabel;
226 }
227
228 /**
229 * Get readOnly.
230 * @return bool
231 */
232 public function isReadOnly(): bool
233 {
234 return $this->readOnly;
235 }
236
237 /**
238 * Get required.
239 * @return bool
240 */
241 public function isRequired(): bool
242 {
243 return $this->required;
244 }
245
246 /**
247 * Get shuffleOptions.
248 * @return bool
249 */
250 public function isShuffleOptions(): bool
251 {
252 return $this->shuffleOptions;
253 }
254
255 /**
256 * Get showValues.
257 * @return bool
258 */
259 public function isShowValues(): bool
260 {
261 return $this->showValues;
262 }
263
264 /**
265 * Get enableSearch.
266 * @return bool
267 */
268 public function isEnableSearch(): bool
269 {
270 return $this->enableSearch;
271 }
272
273 /**
274 * Get visible.
275 * @return bool
276 */
277 public function isVisible(): bool
278 {
279 return $this->visible;
280 }
281
282 /**
283 * Accessor for time settings value object.
284 * @return TimeFieldGeneralSettings
285 */
286 public function getTimeSettings(): TimeFieldGeneralSettings
287 {
288 return $this->timeSettings;
289 }
290
291 /**
292 * Get the phone format.
293 *
294 * @return string
295 */
296 public function getPhoneFormat(): string
297 {
298 return $this->phoneFormat;
299 }
300
301 /**
302 * Set the phone format.
303 *
304 * @param string $format
305 */
306 public function setPhoneFormat(string $format): void
307 {
308 $this->phoneFormat = $format;
309 }
310
311 /**
312 * Get the phone auto-detect setting.
313 *
314 * @return bool
315 */
316 public function isPhoneAutoDetect(): bool
317 {
318 return $this->phoneAutoDetect;
319 }
320
321 /**
322 * Set the phone auto-detect setting.
323 *
324 * @param bool|null $val
325 */
326 public function setPhoneAutoDetect(?bool $val): void
327 {
328 $this->phoneAutoDetect = (bool)$val;
329 }
330 /**
331 * Get the minimum value.
332 *
333 * @return float|null
334 */
335 public function getMinValue(): ?float
336 {
337 return $this->minValue;
338 }
339
340 /**
341 * Set the minimum value.
342 *
343 * @param float|null $minValue
344 */
345 public function setMinValue(?float $minValue): void
346 {
347 $this->minValue = $minValue;
348 }
349
350 /**
351 * Get the maximum value.
352 *
353 * @return float|null
354 */
355 public function getMaxValue(): ?float
356 {
357 return $this->maxValue;
358 }
359
360 /**
361 * Set the maximum value.
362 *
363 * @param float|null $maxValue
364 */
365 public function setMaxValue(?float $maxValue): void
366 {
367 $this->maxValue = $maxValue;
368 }
369
370 /**
371 * Get the step value.
372 *
373 * @return float
374 */
375 public function getStep(): float
376 {
377 return $this->step;
378 }
379
380 /**
381 * Set the step value.
382 *
383 * @param float $step
384 */
385 public function setStep(float $step): void
386 {
387 $this->step = $step;
388 }
389
390 /**
391 * Get the number format.
392 *
393 * @return string
394 */
395 public function getNumberFormat(): string
396 {
397 return $this->numberFormat;
398 }
399
400 /**
401 * Set the number format.
402 *
403 * @param string $numberFormat
404 */
405 public function setNumberFormat(string $numberFormat): void
406 {
407 $this->numberFormat = $numberFormat;
408 }
409
410 /**
411 * @return array<string, mixed>
412 */
413 public function toArray(): array
414 {
415 return array_merge(
416 [
417 'label' => $this->getLabel(),
418 'required' => $this->isRequired(),
419 'placeholder' => $this->getPlaceholder(),
420 'hideLabel' => $this->isHideLabel(),
421 'readOnly' => $this->isReadOnly(),
422 'description' => $this->getDescription(),
423 'requiredMessage' => $this->getRequiredMessage(),
424 'cssClasses' => $this->getCssClasses(),
425 'shuffleOptions' => $this->isShuffleOptions(),
426 'showValues' => $this->isShowValues(),
427 'enableSearch' => $this->isEnableSearch(),
428 'phoneFormat' => $this->getPhoneFormat(),
429 'phoneAutoDetect' => $this->isPhoneAutoDetect(),
430 'minValue' => $this->getMinValue(),
431 'maxValue' => $this->getMaxValue(),
432 'step' => $this->getStep(),
433 'numberFormat' => $this->getNumberFormat(),
434 'visible' => $this->isVisible(),
435 ],
436 $this->timeSettings->toArray()
437 );
438 }
439 }
440