| 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 |
/** |
| 11 |
* Class TimeFieldGeneralSettings |
| 12 |
* |
| 13 |
* Encapsulates time-specific settings extracted from FieldGeneralSettings. |
| 14 |
*/ |
| 15 |
final class TimeFieldGeneralSettings |
| 16 |
{ |
| 17 |
/** |
| 18 |
* @var string |
| 19 |
*/ |
| 20 |
private string $timeFieldType; |
| 21 |
|
| 22 |
/** |
| 23 |
* @var string |
| 24 |
*/ |
| 25 |
private string $timeFormat; |
| 26 |
|
| 27 |
/** |
| 28 |
* @var string|null |
| 29 |
*/ |
| 30 |
private ?string $minTimeValue = null; |
| 31 |
|
| 32 |
/** |
| 33 |
* @var string|null |
| 34 |
*/ |
| 35 |
private ?string $maxTimeValue = null; |
| 36 |
|
| 37 |
/** |
| 38 |
* @var bool |
| 39 |
*/ |
| 40 |
private bool $limitTimeRange = false; |
| 41 |
|
| 42 |
public function __construct( |
| 43 |
bool $limitTimeRange, |
| 44 |
string $timeFieldType = '', |
| 45 |
string $timeFormat = '', |
| 46 |
?string $minTimeValue = null, |
| 47 |
?string $maxTimeValue = null |
| 48 |
) { |
| 49 |
$this->timeFieldType = $timeFieldType; |
| 50 |
$this->timeFormat = $timeFormat; |
| 51 |
$this->minTimeValue = $minTimeValue; |
| 52 |
$this->maxTimeValue = $maxTimeValue; |
| 53 |
$this->limitTimeRange = $limitTimeRange; |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Get timeFieldType. |
| 58 |
*/ |
| 59 |
public function getTimeFieldType(): string |
| 60 |
{ |
| 61 |
return $this->timeFieldType; |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* Set timeFieldType. |
| 66 |
*/ |
| 67 |
public function setTimeFieldType(string $timeFieldType): void |
| 68 |
{ |
| 69 |
$this->timeFieldType = $timeFieldType; |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* Get timeFormat. |
| 74 |
*/ |
| 75 |
public function getTimeFormat(): string |
| 76 |
{ |
| 77 |
return $this->timeFormat; |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* Set timeFormat. |
| 82 |
*/ |
| 83 |
public function setTimeFormat(string $timeFormat): void |
| 84 |
{ |
| 85 |
$this->timeFormat = $timeFormat; |
| 86 |
} |
| 87 |
|
| 88 |
public function getMinTimeValue(): ?string |
| 89 |
{ |
| 90 |
return $this->minTimeValue; |
| 91 |
} |
| 92 |
|
| 93 |
public function setMinTimeValue(?string $minTimeValue): void |
| 94 |
{ |
| 95 |
$this->minTimeValue = $minTimeValue; |
| 96 |
} |
| 97 |
|
| 98 |
public function getMaxTimeValue(): ?string |
| 99 |
{ |
| 100 |
return $this->maxTimeValue; |
| 101 |
} |
| 102 |
|
| 103 |
public function setMaxTimeValue(?string $maxTimeValue): void |
| 104 |
{ |
| 105 |
$this->maxTimeValue = $maxTimeValue; |
| 106 |
} |
| 107 |
|
| 108 |
public function getLimitTimeRange(): bool |
| 109 |
{ |
| 110 |
return $this->limitTimeRange; |
| 111 |
} |
| 112 |
|
| 113 |
public function setLimitTimeRange(bool $limitTimeRange): void |
| 114 |
{ |
| 115 |
$this->limitTimeRange = $limitTimeRange; |
| 116 |
} |
| 117 |
|
| 118 |
/** |
| 119 |
* @return array<string, string|bool|null> |
| 120 |
*/ |
| 121 |
public function toArray(): array |
| 122 |
{ |
| 123 |
return [ |
| 124 |
'timeFieldType' => $this->getTimeFieldType(), |
| 125 |
'timeFormat' => $this->getTimeFormat(), |
| 126 |
'minTimeValue' => $this->getMinTimeValue(), |
| 127 |
'maxTimeValue' => $this->getMaxTimeValue(), |
| 128 |
'limitTimeRange' => $this->getLimitTimeRange(), |
| 129 |
]; |
| 130 |
} |
| 131 |
} |
| 132 |
|