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 / FieldAdvancedSettings.php

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

247 lines 5.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 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 * FieldAdvancedSettings constructor.
61 *
62 * @param string $defaultValue
63 * @param bool $limitMaxLength
64 * @param int $maxLength
65 * @param string $labelPosition
66 * @param bool $noDuplicates
67 * @param string $inputPrefix
68 * @param string $inputSuffix
69 *
70 */
71 public function __construct(
72 string $defaultValue,
73 bool $limitMaxLength,
74 int $maxLength,
75 string $labelPosition,
76 bool $noDuplicates,
77 string $inputPrefix,
78 string $inputSuffix
79 ) {
80 $this->defaultValue = $defaultValue;
81 $this->limitMaxLength = $limitMaxLength;
82 $this->maxLength = $maxLength;
83 $this->labelPosition = $labelPosition;
84 $this->noDuplicates = $noDuplicates;
85 $this->inputPrefix = $inputPrefix;
86 $this->inputSuffix = $inputSuffix;
87 }
88
89 /**
90 * Get the default value.
91 *
92 * @return string
93 */
94 public function getDefaultValue(): string
95 {
96 return $this->defaultValue;
97 }
98
99 /**
100 * Set the default value.
101 *
102 * @param string $defaultValue
103 */
104 public function setDefaultValue(string $defaultValue): void
105 {
106 $this->defaultValue = $defaultValue;
107 }
108
109 /**
110 * Check if maximum length limit is enabled.
111 *
112 * @return bool
113 */
114 public function isLimitMaxLength(): bool
115 {
116 return $this->limitMaxLength;
117 }
118
119 /**
120 * Set the limit maximum length setting.
121 *
122 * @param bool $limitMaxLength
123 */
124 public function setLimitMaxLength(bool $limitMaxLength): void
125 {
126 $this->limitMaxLength = $limitMaxLength;
127 }
128
129 /**
130 * Get the maximum length.
131 *
132 * @return int
133 */
134 public function getMaxLength(): int
135 {
136 return $this->maxLength;
137 }
138
139 /**
140 * Set the maximum length setting.
141 *
142 * @param int $maxLength
143 */
144 public function setMaxLength(int $maxLength): void
145 {
146 $this->maxLength = $maxLength;
147 }
148
149 /**
150 * Get the label position.
151 *
152 * @return string
153 */
154 public function getLabelPosition(): string
155 {
156 return $this->labelPosition;
157 }
158
159 /**
160 * Set the label position setting.
161 *
162 * @param string $labelPosition
163 */
164 public function setLabelPosition(string $labelPosition): void
165 {
166 $this->labelPosition = $labelPosition;
167 }
168
169 /**
170 * Check if duplicates are not allowed.
171 *
172 * @return bool
173 */
174 public function isNoDuplicates(): bool
175 {
176 return $this->noDuplicates;
177 }
178
179 /**
180 * Set the noDuplicates setting.
181 *
182 * @param bool $noDuplicates
183 */
184 public function setNoDuplicates(bool $noDuplicates): void
185 {
186 $this->noDuplicates = $noDuplicates;
187 }
188
189 /**
190 * Get the field prefix.
191 *
192 * @return string
193 */
194 public function getInputPrefix(): string
195 {
196 return $this->inputPrefix;
197 }
198
199 /**
200 * Set the field prefix.
201 *
202 * @param string $prefix
203 */
204 public function setInputPrefix(string $prefix): void
205 {
206 $this->inputPrefix = $prefix;
207 }
208
209 /**
210 * Get the field suffix.
211 *
212 * @return string
213 */
214 public function getInputSuffix(): string
215 {
216 return $this->inputSuffix;
217 }
218
219 /**
220 * Set the field suffix.
221 *
222 * @param string $suffix
223 */
224 public function setInputSuffix(string $suffix): void
225 {
226 $this->inputSuffix = $suffix;
227 }
228
229 /**
230 * Convert the advanced settings to an array.
231 *
232 * @return array<string, mixed>
233 */
234 public function toArray(): array
235 {
236 return [
237 'defaultValue' => $this->getDefaultValue(),
238 'limitMaxLength' => $this->isLimitMaxLength(),
239 'maxLength' => $this->getMaxLength(),
240 'labelPosition' => $this->getLabelPosition(),
241 'noDuplicates' => $this->isNoDuplicates(),
242 'inputPrefix' => $this->getInputPrefix(),
243 'inputSuffix' => $this->getInputSuffix(),
244 ];
245 }
246 }
247