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

189 lines 3.8 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 * FieldAdvancedSettings constructor.
51 *
52 * @param string $defaultValue
53 * @param bool $limitMaxLength
54 * @param int $maxLength
55 * @param string $labelPosition
56 * @param bool $noDuplicates
57 *
58 */
59 public function __construct(
60 string $defaultValue,
61 bool $limitMaxLength,
62 int $maxLength,
63 string $labelPosition,
64 bool $noDuplicates
65 ) {
66 $this->defaultValue = $defaultValue;
67 $this->limitMaxLength = $limitMaxLength;
68 $this->maxLength = $maxLength;
69 $this->labelPosition = $labelPosition;
70 $this->noDuplicates = $noDuplicates;
71 }
72
73 /**
74 * Get the default value.
75 *
76 * @return string
77 */
78 public function getDefaultValue(): string
79 {
80 return $this->defaultValue;
81 }
82
83 /**
84 * Set the default value.
85 *
86 * @param string $defaultValue
87 */
88 public function setDefaultValue(string $defaultValue): void
89 {
90 $this->defaultValue = $defaultValue;
91 }
92
93 /**
94 * Check if maximum length limit is enabled.
95 *
96 * @return bool
97 */
98 public function isLimitMaxLength(): bool
99 {
100 return $this->limitMaxLength;
101 }
102
103 /**
104 * Set the limit maximum length setting.
105 *
106 * @param bool $limitMaxLength
107 */
108 public function setLimitMaxLength(bool $limitMaxLength): void
109 {
110 $this->limitMaxLength = $limitMaxLength;
111 }
112
113 /**
114 * Get the maximum length.
115 *
116 * @return int
117 */
118 public function getMaxLength(): int
119 {
120 return $this->maxLength;
121 }
122
123 /**
124 * Set the maximum length setting.
125 *
126 * @param int $maxLength
127 */
128 public function setMaxLength(int $maxLength): void
129 {
130 $this->maxLength = $maxLength;
131 }
132
133 /**
134 * Get the label position.
135 *
136 * @return string
137 */
138 public function getLabelPosition(): string
139 {
140 return $this->labelPosition;
141 }
142
143 /**
144 * Set the label position setting.
145 *
146 * @param string $labelPosition
147 */
148 public function setLabelPosition(string $labelPosition): void
149 {
150 $this->labelPosition = $labelPosition;
151 }
152
153 /**
154 * Check if duplicates are not allowed.
155 *
156 * @return bool
157 */
158 public function isNoDuplicates(): bool
159 {
160 return $this->noDuplicates;
161 }
162
163 /**
164 * Set the noDuplicates setting.
165 *
166 * @param bool $noDuplicates
167 */
168 public function setNoDuplicates(bool $noDuplicates): void
169 {
170 $this->noDuplicates = $noDuplicates;
171 }
172
173 /**
174 * Convert the advanced settings to an array.
175 *
176 * @return array<string, mixed>
177 */
178 public function toArray(): array
179 {
180 return [
181 'defaultValue' => $this->getDefaultValue(),
182 'limitMaxLength' => $this->isLimitMaxLength(),
183 'maxLength' => $this->getMaxLength(),
184 'labelPosition' => $this->getLabelPosition(),
185 'noDuplicates' => $this->isNoDuplicates(),
186 ];
187 }
188 }
189