| 1 |
<?php |
| 2 |
|
| 3 |
namespace IvyForms\Entity\Field; |
| 4 |
|
| 5 |
use IvyForms\ValueObjects\Field\FieldAdvancedSettings as FieldAdvancedSettingsVO; |
| 6 |
|
| 7 |
// phpcs:disable PSR1.Files.SideEffects |
| 8 |
if (!defined('ABSPATH')) { |
| 9 |
exit; // Exit if accessed directly |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Class fieldAdvancedSettings |
| 14 |
* |
| 15 |
* Entity wrapper for fieldAdvancedSettings ValueObject. |
| 16 |
*/ |
| 17 |
class FieldAdvancedSettings |
| 18 |
{ |
| 19 |
private FieldAdvancedSettingsVO $fieldAdvancedSettings; |
| 20 |
|
| 21 |
/** |
| 22 |
* @param FieldAdvancedSettingsVO $fieldAdvancedSettings |
| 23 |
*/ |
| 24 |
public function __construct(FieldAdvancedSettingsVO $fieldAdvancedSettings) |
| 25 |
{ |
| 26 |
$this->fieldAdvancedSettings = $fieldAdvancedSettings; |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Check if maximum length limit is enabled. |
| 31 |
* |
| 32 |
* @return bool |
| 33 |
*/ |
| 34 |
public function isLimitMaxLength(): bool |
| 35 |
{ |
| 36 |
return $this->fieldAdvancedSettings->isLimitMaxLength(); |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Set the limit maximum length setting. |
| 41 |
* |
| 42 |
* @param bool $limitMaxLength |
| 43 |
*/ |
| 44 |
public function setLimitMaxLength(bool $limitMaxLength): void |
| 45 |
{ |
| 46 |
$this->fieldAdvancedSettings->setLimitMaxLength($limitMaxLength); |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Get the maximum length. |
| 51 |
* |
| 52 |
* @return int |
| 53 |
*/ |
| 54 |
public function getMaxLength(): int |
| 55 |
{ |
| 56 |
return $this->fieldAdvancedSettings->getMaxLength(); |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* Set the maximum length setting. |
| 61 |
* |
| 62 |
* @param int $maxLength |
| 63 |
*/ |
| 64 |
public function setMaxLength(int $maxLength): void |
| 65 |
{ |
| 66 |
$this->fieldAdvancedSettings->setMaxLength($maxLength); |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Get the label position. |
| 71 |
* |
| 72 |
* @return string |
| 73 |
*/ |
| 74 |
public function getLabelPosition(): string |
| 75 |
{ |
| 76 |
return $this->fieldAdvancedSettings->getLabelPosition(); |
| 77 |
} |
| 78 |
|
| 79 |
/** |
| 80 |
* Set the label position setting. |
| 81 |
* |
| 82 |
* @param string $labelPosition |
| 83 |
*/ |
| 84 |
public function setLabelPosition(string $labelPosition): void |
| 85 |
{ |
| 86 |
$this->fieldAdvancedSettings->setLabelPosition($labelPosition); |
| 87 |
} |
| 88 |
|
| 89 |
/** |
| 90 |
* Check if no duplicates is enabled. |
| 91 |
* |
| 92 |
* @return bool |
| 93 |
*/ |
| 94 |
public function isNoDuplicates(): bool |
| 95 |
{ |
| 96 |
return $this->fieldAdvancedSettings->isNoDuplicates(); |
| 97 |
} |
| 98 |
|
| 99 |
/** |
| 100 |
* Set the no duplicates setting. |
| 101 |
* |
| 102 |
* @param bool $noDuplicates |
| 103 |
*/ |
| 104 |
public function setNoDuplicates(bool $noDuplicates): void |
| 105 |
{ |
| 106 |
$this->fieldAdvancedSettings->setNoDuplicates($noDuplicates); |
| 107 |
} |
| 108 |
|
| 109 |
/** |
| 110 |
* Get the default value of the form field. |
| 111 |
* |
| 112 |
* @return string The default value of the form field. |
| 113 |
*/ |
| 114 |
public function getDefaultValue(): string |
| 115 |
{ |
| 116 |
return $this->fieldAdvancedSettings->getDefaultValue(); |
| 117 |
} |
| 118 |
|
| 119 |
/** |
| 120 |
* Set the default value of the form field. |
| 121 |
* |
| 122 |
* @param string $defaultValue The default value to set. |
| 123 |
*/ |
| 124 |
public function setDefaultValue(string $defaultValue): void |
| 125 |
{ |
| 126 |
$this->fieldAdvancedSettings->setDefaultValue($defaultValue); |
| 127 |
} |
| 128 |
|
| 129 |
/** |
| 130 |
* Get the field prefix. |
| 131 |
* |
| 132 |
* @return string |
| 133 |
*/ |
| 134 |
public function getInputPrefix(): string |
| 135 |
{ |
| 136 |
return $this->fieldAdvancedSettings->getInputPrefix(); |
| 137 |
} |
| 138 |
|
| 139 |
/** |
| 140 |
* Set the field prefix. |
| 141 |
* |
| 142 |
* @param string $prefix |
| 143 |
*/ |
| 144 |
public function setInputPrefix(string $prefix): void |
| 145 |
{ |
| 146 |
$this->fieldAdvancedSettings->setInputPrefix($prefix); |
| 147 |
} |
| 148 |
|
| 149 |
/** |
| 150 |
* Get the field suffix. |
| 151 |
* |
| 152 |
* @return string |
| 153 |
*/ |
| 154 |
public function getInputSuffix(): string |
| 155 |
{ |
| 156 |
return $this->fieldAdvancedSettings->getInputSuffix(); |
| 157 |
} |
| 158 |
|
| 159 |
/** |
| 160 |
* Set the field suffix. |
| 161 |
* |
| 162 |
* @param string $suffix |
| 163 |
*/ |
| 164 |
public function setInputSuffix(string $suffix): void |
| 165 |
{ |
| 166 |
$this->fieldAdvancedSettings->setInputSuffix($suffix); |
| 167 |
} |
| 168 |
|
| 169 |
/** |
| 170 |
* @return array<string, bool|string> |
| 171 |
*/ |
| 172 |
public function toArray(): array |
| 173 |
{ |
| 174 |
return $this->fieldAdvancedSettings->toArray(); |
| 175 |
} |
| 176 |
} |
| 177 |
|