| 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 |
/** |
| 16 |
* Class ConfirmationGeneralSettings |
| 17 |
* |
| 18 |
* Encapsulates confirmation field settings (email/password confirmation). |
| 19 |
*/ |
| 20 |
final class ConfirmationGeneralSettings |
| 21 |
{ |
| 22 |
/** |
| 23 |
* @var bool |
| 24 |
*/ |
| 25 |
private bool $confirmFieldEnabled; |
| 26 |
|
| 27 |
/** |
| 28 |
* @var string |
| 29 |
*/ |
| 30 |
private string $confirmFieldLabel; |
| 31 |
|
| 32 |
/** |
| 33 |
* @var string |
| 34 |
*/ |
| 35 |
private string $confirmFieldPlaceholder; |
| 36 |
|
| 37 |
/** |
| 38 |
* @var bool |
| 39 |
*/ |
| 40 |
private bool $confirmFieldHideLabel; |
| 41 |
|
| 42 |
/** |
| 43 |
* @param bool $confirmFieldEnabled |
| 44 |
* @param string $confirmFieldLabel |
| 45 |
* @param string $confirmFieldPlaceholder |
| 46 |
* @param bool $confirmFieldHideLabel |
| 47 |
* |
| 48 |
*/ |
| 49 |
public function __construct( |
| 50 |
bool $confirmFieldEnabled, |
| 51 |
string $confirmFieldLabel, |
| 52 |
string $confirmFieldPlaceholder, |
| 53 |
bool $confirmFieldHideLabel |
| 54 |
) { |
| 55 |
$this->confirmFieldEnabled = $confirmFieldEnabled; |
| 56 |
$this->confirmFieldLabel = $confirmFieldLabel; |
| 57 |
$this->confirmFieldPlaceholder = $confirmFieldPlaceholder; |
| 58 |
$this->confirmFieldHideLabel = $confirmFieldHideLabel; |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* Get confirmFieldEnabled. |
| 63 |
*/ |
| 64 |
public function isConfirmFieldEnabled(): bool |
| 65 |
{ |
| 66 |
return $this->confirmFieldEnabled; |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Set confirmFieldEnabled. |
| 71 |
*/ |
| 72 |
public function setConfirmFieldEnabled(bool $enabled): void |
| 73 |
{ |
| 74 |
$this->confirmFieldEnabled = $enabled; |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* Get confirmFieldLabel. |
| 79 |
*/ |
| 80 |
public function getConfirmFieldLabel(): string |
| 81 |
{ |
| 82 |
return $this->confirmFieldLabel; |
| 83 |
} |
| 84 |
|
| 85 |
/** |
| 86 |
* Set confirmFieldLabel. |
| 87 |
*/ |
| 88 |
public function setConfirmFieldLabel(string $label): void |
| 89 |
{ |
| 90 |
$this->confirmFieldLabel = $label; |
| 91 |
} |
| 92 |
|
| 93 |
/** |
| 94 |
* Get confirmFieldPlaceholder. |
| 95 |
*/ |
| 96 |
public function getConfirmFieldPlaceholder(): string |
| 97 |
{ |
| 98 |
return $this->confirmFieldPlaceholder; |
| 99 |
} |
| 100 |
|
| 101 |
/** |
| 102 |
* Set confirmFieldPlaceholder. |
| 103 |
*/ |
| 104 |
public function setConfirmFieldPlaceholder(string $placeholder): void |
| 105 |
{ |
| 106 |
$this->confirmFieldPlaceholder = $placeholder; |
| 107 |
} |
| 108 |
|
| 109 |
/** |
| 110 |
* Get confirmFieldHideLabel. |
| 111 |
*/ |
| 112 |
public function isConfirmFieldHideLabel(): bool |
| 113 |
{ |
| 114 |
return $this->confirmFieldHideLabel; |
| 115 |
} |
| 116 |
|
| 117 |
/** |
| 118 |
* Set confirmFieldHideLabel. |
| 119 |
*/ |
| 120 |
public function setConfirmFieldHideLabel(bool $hideLabel): void |
| 121 |
{ |
| 122 |
$this->confirmFieldHideLabel = $hideLabel; |
| 123 |
} |
| 124 |
|
| 125 |
/** |
| 126 |
* @return array<string, mixed> |
| 127 |
*/ |
| 128 |
public function toArray(): array |
| 129 |
{ |
| 130 |
return [ |
| 131 |
'confirmFieldEnabled' => $this->isConfirmFieldEnabled(), |
| 132 |
'confirmFieldLabel' => $this->getConfirmFieldLabel(), |
| 133 |
'confirmFieldPlaceholder' => $this->getConfirmFieldPlaceholder(), |
| 134 |
'confirmFieldHideLabel' => $this->isConfirmFieldHideLabel(), |
| 135 |
]; |
| 136 |
} |
| 137 |
} |
| 138 |
|