PluginProbe
The Innovative Form Builder – IvyForms / 1.5.1
The Innovative Form Builder – IvyForms v1.5.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
← All changes | backend/src/ValueObjects/Confirmation/Confirmation.php +97 -9 1.0 → 1.5.1 View file →
@@ -9,8 +9,11 @@
9 9 /**
10 10 * Class Confirmation
11 11 *
12 12 * @package IvyForms\ValueObjects\Confirmation
13 + *
14 + * @SuppressWarnings(PHPMD.ExcessiveParameterList)
15 + * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
13 16 */
14 17 final class Confirmation
15 18 {
16 19 /**
@@ -23,8 +26,12 @@
23 26 public int $formId;
24 27 /**
25 28 * @var string
26 29 */
30 + public string $name;
31 + /**
32 + * @var string
33 + */
27 34 public string $type;
28 35 /**
29 36 * @var bool
30 37 */
@@ -44,8 +51,20 @@
44 51 /**
45 52 * @var string
46 53 */
47 54 public string $page;
55 + /**
56 + * @var int
57 + */
58 + public int $position;
59 + /**
60 + * @var bool
61 + */
62 + public bool $isDefault;
63 + /**
64 + * @var array<string, mixed>
65 + */
66 + public array $smartLogic;
48 67
49 68 /**
50 69 * Confirmation constructor.
51 70 *
@@ -50,8 +69,9 @@
50 69 * Confirmation constructor.
51 70 *
52 71 * @param int $id
53 72 * @param int $formId
73 + * @param string $name
54 74 * @param string $type
55 75 * @param bool $enabled
56 76 * @param bool $showForm
57 77 * @param string $message
@@ -56,28 +76,39 @@
56 76 * @param bool $showForm
57 77 * @param string $message
58 78 * @param string $url
59 79 * @param string $page
80 + * @param int $position
81 + * @param bool $isDefault
82 + * @param array<string, mixed> $smartLogic
60 83 * @throws InvalidArgumentException|ValidationException
61 84 */
62 85 public function __construct(
63 86 int $id,
64 87 int $formId,
88 + string $name,
65 89 string $type,
66 90 bool $enabled,
67 91 bool $showForm,
68 92 string $message,
69 93 string $url,
70 - string $page
94 + string $page,
95 + int $position = 0,
96 + bool $isDefault = false,
97 + array $smartLogic = []
71 98 ) {
72 - $this->id = $this->validateId($id);
73 - $this->formId = $this->validateId($formId);
74 - $this->type = $this->validateString($type, 255, 'type');
75 - $this->enabled = $this->validateBool($enabled);
76 - $this->showForm = $this->validateBool($showForm);
77 - $this->message = $this->validateString($message, 4294967295, 'message');
78 - $this->url = $this->validateString($url, 255, 'url');
79 - $this->page = $this->validateString($page, 255, 'page');
99 + $this->id = $this->validateId($id);
100 + $this->formId = $this->validateId($formId);
101 + $this->name = $this->validateString($name, 255, 'name');
102 + $this->type = $this->validateString($type, 255, 'type');
103 + $this->enabled = $this->validateBool($enabled);
104 + $this->showForm = $this->validateBool($showForm);
105 + $this->message = $this->validateString($message, 4294967295, 'message');
106 + $this->url = $this->validateString($url, 255, 'url');
107 + $this->page = $this->validateString($page, 255, 'page');
108 + $this->position = $position >= 0 ? $position : 0;
109 + $this->isDefault = $this->validateBool($isDefault);
110 + $this->smartLogic = $this->validateSmartLogic($smartLogic);
80 111 }
81 112
82 113 /**
83 114 * Validates the ID.
@@ -143,8 +174,18 @@
143 174 return $this->id;
144 175 }
145 176
146 177 /**
178 + * Get the confirmation name.
179 + *
180 + * @return string
181 + */
182 + public function getName(): string
183 + {
184 + return $this->name;
185 + }
186 +
187 + /**
147 188 * Get the form ID.
148 189 *
149 190 * @return int
150 191 */
@@ -213,8 +254,51 @@
213 254 return $this->page;
214 255 }
215 256
216 257 /**
258 + * Get the confirmation list position.
259 + *
260 + * @return int
261 + */
262 + public function getPosition(): int
263 + {
264 + return $this->position;
265 + }
266 +
267 + /**
268 + * Whether this confirmation is the default for the form.
269 + *
270 + * @return bool
271 + */
272 + public function isDefault(): bool
273 + {
274 + return $this->isDefault;
275 + }
276 +
277 + /**
278 + * @return array<string, mixed>
279 + */
280 + public function getSmartLogic(): array
281 + {
282 + return $this->smartLogic;
283 + }
284 +
285 + /**
286 + * @param array<string, mixed> $smartLogic
287 + * @return array<string, mixed>
288 + */
289 + private function validateSmartLogic(array $smartLogic): array
290 + {
291 + $match = $smartLogic['match'] ?? 'any';
292 +
293 + return [
294 + 'enabled' => (bool)($smartLogic['enabled'] ?? false),
295 + 'match' => in_array($match, ['any', 'all'], true) ? $match : 'any',
296 + 'rules' => is_array($smartLogic['rules'] ?? null) ? $smartLogic['rules'] : [],
297 + ];
298 + }
299 +
300 + /**
217 301 * Convert the confirmation to an array.
218 302 *
219 303 * @return array<string, mixed>
220 304 */
@@ -222,8 +306,9 @@
222 306 {
223 307 return [
224 308 'id' => $this->getId(),
225 309 'formId' => $this->getFormId(),
310 + 'name' => $this->getName(),
226 311 'type' => $this->getType(),
227 312 'enabled' => $this->isEnabled(),
228 313 'showForm' => $this->isShowForm(),
229 314 'message' => $this->getMessage(),
@@ -228,7 +313,10 @@
228 313 'showForm' => $this->isShowForm(),
229 314 'message' => $this->getMessage(),
230 315 'url' => $this->getUrl(),
231 316 'page' => $this->getPage(),
317 + 'position' => $this->getPosition(),
318 + 'isDefault' => $this->isDefault(),
319 + 'smartLogic' => $this->getSmartLogic(),
232 320 ];
233 321 }
234 322 }