| 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 DateFieldGeneralSettings |
| 17 |
* |
| 18 |
* Encapsulates date-specific settings extracted from FieldGeneralSettings. |
| 19 |
*/ |
| 20 |
final class DateFieldGeneralSettings |
| 21 |
{ |
| 22 |
/** |
| 23 |
* @var string |
| 24 |
*/ |
| 25 |
private string $dateFieldType; |
| 26 |
|
| 27 |
/** |
| 28 |
* @var string |
| 29 |
*/ |
| 30 |
private string $dateFormat; |
| 31 |
|
| 32 |
/** |
| 33 |
* @var string|null |
| 34 |
*/ |
| 35 |
private ?string $minDateValue; |
| 36 |
|
| 37 |
/** |
| 38 |
* @var string|null |
| 39 |
*/ |
| 40 |
private ?string $maxDateValue; |
| 41 |
|
| 42 |
public function __construct( |
| 43 |
string $dateFieldType = '', |
| 44 |
string $dateFormat = '', |
| 45 |
?string $minDateValue = null, |
| 46 |
?string $maxDateValue = null |
| 47 |
) { |
| 48 |
$this->dateFieldType = $dateFieldType; |
| 49 |
$this->dateFormat = $dateFormat; |
| 50 |
$this->minDateValue = $minDateValue; |
| 51 |
$this->maxDateValue = $maxDateValue; |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Get dateFieldType. |
| 56 |
*/ |
| 57 |
public function getDateFieldType(): string |
| 58 |
{ |
| 59 |
return $this->dateFieldType; |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Set dateFieldType. |
| 64 |
*/ |
| 65 |
public function setDateFieldType(string $dateFieldType): void |
| 66 |
{ |
| 67 |
$this->dateFieldType = $dateFieldType; |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* Get dateFormat. |
| 72 |
*/ |
| 73 |
public function getDateFormat(): string |
| 74 |
{ |
| 75 |
return $this->dateFormat; |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* Set dateFormat. |
| 80 |
*/ |
| 81 |
public function setDateFormat(string $dateFormat): void |
| 82 |
{ |
| 83 |
$this->dateFormat = $dateFormat; |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* Get minDateValue. |
| 88 |
*/ |
| 89 |
public function getMinDateValue(): ?string |
| 90 |
{ |
| 91 |
return $this->minDateValue; |
| 92 |
} |
| 93 |
|
| 94 |
/** |
| 95 |
* Set minDateValue. |
| 96 |
*/ |
| 97 |
public function setMinDateValue(?string $minDateValue): void |
| 98 |
{ |
| 99 |
$this->minDateValue = $minDateValue; |
| 100 |
} |
| 101 |
|
| 102 |
/** |
| 103 |
* Get maxDateValue. |
| 104 |
*/ |
| 105 |
public function getMaxDateValue(): ?string |
| 106 |
{ |
| 107 |
return $this->maxDateValue; |
| 108 |
} |
| 109 |
|
| 110 |
/** |
| 111 |
* Set maxDateValue. |
| 112 |
*/ |
| 113 |
public function setMaxDateValue(?string $maxDateValue): void |
| 114 |
{ |
| 115 |
$this->maxDateValue = $maxDateValue; |
| 116 |
} |
| 117 |
|
| 118 |
/** |
| 119 |
* @return array<string, string|null> |
| 120 |
*/ |
| 121 |
public function toArray(): array |
| 122 |
{ |
| 123 |
return [ |
| 124 |
'dateFieldType' => $this->getDateFieldType(), |
| 125 |
'dateFormat' => $this->getDateFormat(), |
| 126 |
'minDateValue' => $this->getMinDateValue(), |
| 127 |
'maxDateValue' => $this->getMaxDateValue(), |
| 128 |
]; |
| 129 |
} |
| 130 |
} |
| 131 |
|