| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* @copyright © Melograno Venture Studio. 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 |
* @var bool |
| 43 |
*/ |
| 44 |
private bool $limitDateRange; |
| 45 |
|
| 46 |
public function __construct( |
| 47 |
bool $limitDateRange, |
| 48 |
string $dateFieldType = '', |
| 49 |
string $dateFormat = '', |
| 50 |
?string $minDateValue = null, |
| 51 |
?string $maxDateValue = null |
| 52 |
) { |
| 53 |
$this->limitDateRange = $limitDateRange; |
| 54 |
$this->dateFieldType = $dateFieldType; |
| 55 |
$this->dateFormat = $dateFormat; |
| 56 |
$this->minDateValue = $minDateValue; |
| 57 |
$this->maxDateValue = $maxDateValue; |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Get dateFieldType. |
| 62 |
*/ |
| 63 |
public function getDateFieldType(): string |
| 64 |
{ |
| 65 |
return $this->dateFieldType; |
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* Set dateFieldType. |
| 70 |
*/ |
| 71 |
public function setDateFieldType(string $dateFieldType): void |
| 72 |
{ |
| 73 |
$this->dateFieldType = $dateFieldType; |
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* Get dateFormat. |
| 78 |
*/ |
| 79 |
public function getDateFormat(): string |
| 80 |
{ |
| 81 |
return $this->dateFormat; |
| 82 |
} |
| 83 |
|
| 84 |
/** |
| 85 |
* Set dateFormat. |
| 86 |
*/ |
| 87 |
public function setDateFormat(string $dateFormat): void |
| 88 |
{ |
| 89 |
$this->dateFormat = $dateFormat; |
| 90 |
} |
| 91 |
|
| 92 |
/** |
| 93 |
* Get minDateValue. |
| 94 |
*/ |
| 95 |
public function getMinDateValue(): ?string |
| 96 |
{ |
| 97 |
return $this->minDateValue; |
| 98 |
} |
| 99 |
|
| 100 |
/** |
| 101 |
* Set minDateValue. |
| 102 |
*/ |
| 103 |
public function setMinDateValue(?string $minDateValue): void |
| 104 |
{ |
| 105 |
$this->minDateValue = $minDateValue; |
| 106 |
} |
| 107 |
|
| 108 |
/** |
| 109 |
* Get maxDateValue. |
| 110 |
*/ |
| 111 |
public function getMaxDateValue(): ?string |
| 112 |
{ |
| 113 |
return $this->maxDateValue; |
| 114 |
} |
| 115 |
|
| 116 |
/** |
| 117 |
* Set maxDateValue. |
| 118 |
*/ |
| 119 |
public function setMaxDateValue(?string $maxDateValue): void |
| 120 |
{ |
| 121 |
$this->maxDateValue = $maxDateValue; |
| 122 |
} |
| 123 |
|
| 124 |
/** |
| 125 |
* @return bool |
| 126 |
*/ |
| 127 |
public function isLimitDateRange(): bool |
| 128 |
{ |
| 129 |
return $this->limitDateRange; |
| 130 |
} |
| 131 |
|
| 132 |
/** |
| 133 |
* @param bool $limitDateRange |
| 134 |
*/ |
| 135 |
public function setLimitDateRange(bool $limitDateRange): void |
| 136 |
{ |
| 137 |
$this->limitDateRange = $limitDateRange; |
| 138 |
} |
| 139 |
|
| 140 |
/** |
| 141 |
* @return array<string, string|bool|null> |
| 142 |
*/ |
| 143 |
public function toArray(): array |
| 144 |
{ |
| 145 |
return [ |
| 146 |
'dateFieldType' => $this->getDateFieldType(), |
| 147 |
'dateFormat' => $this->getDateFormat(), |
| 148 |
'minDateValue' => $this->getMinDateValue(), |
| 149 |
'maxDateValue' => $this->getMaxDateValue(), |
| 150 |
'limitDateRange' => $this->isLimitDateRange(), |
| 151 |
]; |
| 152 |
} |
| 153 |
} |
| 154 |
|