PluginProbe
The Innovative Form Builder – IvyForms / 0.9.1
The Innovative Form Builder – IvyForms v0.9.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 / FieldAdvancedSettings.php

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

276 lines 5.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
17 /**
18 * Class FieldAdvancedSettings
19 *
20 * @package IvyForms\ValueObjects\Field
21 */
22 final class FieldAdvancedSettings
23 {
24 /**
25 * @var string
26 */
27 public string $defaultValue;
28
29 /**
30 * @var bool
31 */
32 public bool $limitMaxLength;
33
34 /**
35 * @var int
36 */
37 public int $maxLength;
38
39 /**
40 * @var string
41 */
42 public string $labelPosition;
43
44 /**
45 * @var bool
46 */
47 public bool $noDuplicates;
48
49 /**
50 * @var string field prefix (e.g., https://)
51 */
52 private string $inputPrefix;
53
54 /**
55 * @var string field suffix (e.g., .com)
56 */
57 private string $inputSuffix;
58
59 /**
60 * @var string Type of rating icon (star, heart, etc.)
61 */
62 private string $ratingIcon;
63
64 /**
65 * FieldAdvancedSettings constructor.
66 *
67 * @param string $defaultValue
68 * @param bool $limitMaxLength
69 * @param int $maxLength
70 * @param string $labelPosition
71 * @param bool $noDuplicates
72 * @param string $inputPrefix
73 * @param string $inputSuffix
74 * @param string $ratingIcon
75 *
76 */
77 public function __construct(
78 string $defaultValue,
79 bool $limitMaxLength,
80 int $maxLength,
81 string $labelPosition,
82 bool $noDuplicates,
83 string $inputPrefix,
84 string $inputSuffix,
85 string $ratingIcon
86 ) {
87 $this->defaultValue = $defaultValue;
88 $this->limitMaxLength = $limitMaxLength;
89 $this->maxLength = $maxLength;
90 $this->labelPosition = $labelPosition;
91 $this->noDuplicates = $noDuplicates;
92 $this->inputPrefix = $inputPrefix;
93 $this->inputSuffix = $inputSuffix;
94 $this->ratingIcon = $ratingIcon;
95 }
96
97 /**
98 * Get the default value.
99 *
100 * @return string
101 */
102 public function getDefaultValue(): string
103 {
104 return $this->defaultValue;
105 }
106
107 /**
108 * Set the default value.
109 *
110 * @param string $defaultValue
111 */
112 public function setDefaultValue(string $defaultValue): void
113 {
114 $this->defaultValue = $defaultValue;
115 }
116
117 /**
118 * Check if maximum length limit is enabled.
119 *
120 * @return bool
121 */
122 public function isLimitMaxLength(): bool
123 {
124 return $this->limitMaxLength;
125 }
126
127 /**
128 * Set the limit maximum length setting.
129 *
130 * @param bool $limitMaxLength
131 */
132 public function setLimitMaxLength(bool $limitMaxLength): void
133 {
134 $this->limitMaxLength = $limitMaxLength;
135 }
136
137 /**
138 * Get the maximum length.
139 *
140 * @return int
141 */
142 public function getMaxLength(): int
143 {
144 return $this->maxLength;
145 }
146
147 /**
148 * Set the maximum length setting.
149 *
150 * @param int $maxLength
151 */
152 public function setMaxLength(int $maxLength): void
153 {
154 $this->maxLength = $maxLength;
155 }
156
157 /**
158 * Get the label position.
159 *
160 * @return string
161 */
162 public function getLabelPosition(): string
163 {
164 return $this->labelPosition;
165 }
166
167 /**
168 * Set the label position setting.
169 *
170 * @param string $labelPosition
171 */
172 public function setLabelPosition(string $labelPosition): void
173 {
174 $this->labelPosition = $labelPosition;
175 }
176
177 /**
178 * Check if duplicates are not allowed.
179 *
180 * @return bool
181 */
182 public function isNoDuplicates(): bool
183 {
184 return $this->noDuplicates;
185 }
186
187 /**
188 * Set the noDuplicates setting.
189 *
190 * @param bool $noDuplicates
191 */
192 public function setNoDuplicates(bool $noDuplicates): void
193 {
194 $this->noDuplicates = $noDuplicates;
195 }
196
197 /**
198 * Get the field prefix.
199 *
200 * @return string
201 */
202 public function getInputPrefix(): string
203 {
204 return $this->inputPrefix;
205 }
206
207 /**
208 * Set the field prefix.
209 *
210 * @param string $prefix
211 */
212 public function setInputPrefix(string $prefix): void
213 {
214 $this->inputPrefix = $prefix;
215 }
216
217 /**
218 * Get the field suffix.
219 *
220 * @return string
221 */
222 public function getInputSuffix(): string
223 {
224 return $this->inputSuffix;
225 }
226
227 /**
228 * Set the field suffix.
229 *
230 * @param string $suffix
231 */
232 public function setInputSuffix(string $suffix): void
233 {
234 $this->inputSuffix = $suffix;
235 }
236
237 /**
238 * Get the rating icon type.
239 *
240 * @return string
241 */
242 public function getRatingIcon(): string
243 {
244 return $this->ratingIcon;
245 }
246
247 /**
248 * Set the rating icon type.
249 *
250 * @param string $ratingIcon
251 */
252 public function setRatingIcon(string $ratingIcon): void
253 {
254 $this->ratingIcon = $ratingIcon;
255 }
256
257 /**
258 * Convert the advanced settings to an array.
259 *
260 * @return array<string, mixed>
261 */
262 public function toArray(): array
263 {
264 return [
265 'defaultValue' => $this->getDefaultValue(),
266 'limitMaxLength' => $this->isLimitMaxLength(),
267 'maxLength' => $this->getMaxLength(),
268 'labelPosition' => $this->getLabelPosition(),
269 'noDuplicates' => $this->isNoDuplicates(),
270 'inputPrefix' => $this->getInputPrefix(),
271 'inputSuffix' => $this->getInputSuffix(),
272 'ratingIcon' => $this->getRatingIcon(),
273 ];
274 }
275 }
276