| 1 |
<?php |
| 2 |
|
| 3 |
namespace Give\Framework\FieldsAPI\Properties\DonationForm; |
| 4 |
|
| 5 |
use JsonSerializable; |
| 6 |
|
| 7 |
/** |
| 8 |
* @since 3.0.0 |
| 9 |
*/ |
| 10 |
class CurrencySwitcherSetting implements JsonSerializable |
| 11 |
{ |
| 12 |
/** |
| 13 |
* @var string |
| 14 |
*/ |
| 15 |
protected $id; |
| 16 |
/** |
| 17 |
* @var float |
| 18 |
*/ |
| 19 |
protected $exchangeRate; |
| 20 |
/** |
| 21 |
* @var string[] |
| 22 |
*/ |
| 23 |
protected $gateways = []; |
| 24 |
/** |
| 25 |
* @var int |
| 26 |
*/ |
| 27 |
protected $exchangeRateFractionDigits; |
| 28 |
|
| 29 |
/** |
| 30 |
* @since 3.0.0 |
| 31 |
*/ |
| 32 |
public function __construct( |
| 33 |
string $id, |
| 34 |
float $exchangeRate = 0, |
| 35 |
array $gateways = [], |
| 36 |
int $exchangeRateFractionDigits = 2 |
| 37 |
) { |
| 38 |
$this->id = $id; |
| 39 |
$this->exchangeRate = $exchangeRate; |
| 40 |
$this->gateways = $gateways; |
| 41 |
$this->exchangeRateFractionDigits = $exchangeRateFractionDigits; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* @since 3.0.0 |
| 46 |
*/ |
| 47 |
#[\ReturnTypeWillChange] |
| 48 |
public function jsonSerialize() |
| 49 |
{ |
| 50 |
return get_object_vars($this); |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* @since 3.0.0 |
| 55 |
*/ |
| 56 |
public function id(string $id): CurrencySwitcherSetting |
| 57 |
{ |
| 58 |
$this->id = $id; |
| 59 |
|
| 60 |
return $this; |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* @since 3.0.0 |
| 65 |
*/ |
| 66 |
public function getId(): string |
| 67 |
{ |
| 68 |
return $this->id; |
| 69 |
} |
| 70 |
|
| 71 |
/** |
| 72 |
* @since 3.0.0 |
| 73 |
*/ |
| 74 |
public function exchangeRate(float $rate): CurrencySwitcherSetting |
| 75 |
{ |
| 76 |
$this->exchangeRate = $rate; |
| 77 |
|
| 78 |
return $this; |
| 79 |
} |
| 80 |
|
| 81 |
/** |
| 82 |
* @since 3.0.0 |
| 83 |
*/ |
| 84 |
public function getExchangeRate(): float |
| 85 |
{ |
| 86 |
return $this->exchangeRate; |
| 87 |
} |
| 88 |
|
| 89 |
/** |
| 90 |
* @since 3.0.0 |
| 91 |
*/ |
| 92 |
public function exchangeRateFractionDigits(int $exchangeRateFractionDigits): CurrencySwitcherSetting |
| 93 |
{ |
| 94 |
$this->exchangeRateFractionDigits = $exchangeRateFractionDigits; |
| 95 |
|
| 96 |
return $this; |
| 97 |
} |
| 98 |
|
| 99 |
/** |
| 100 |
* @since 3.0.0 |
| 101 |
*/ |
| 102 |
public function getExchangeRateFractionDigits(): int |
| 103 |
{ |
| 104 |
return $this->exchangeRateFractionDigits; |
| 105 |
} |
| 106 |
|
| 107 |
/** |
| 108 |
* @since 3.0.0 |
| 109 |
*/ |
| 110 |
public function gateways(array $gateways): CurrencySwitcherSetting |
| 111 |
{ |
| 112 |
$this->gateways = $gateways; |
| 113 |
|
| 114 |
return $this; |
| 115 |
} |
| 116 |
|
| 117 |
/** |
| 118 |
* @return array|string[] |
| 119 |
*/ |
| 120 |
public function getGateways(): array |
| 121 |
{ |
| 122 |
return $this->gateways; |
| 123 |
} |
| 124 |
} |
| 125 |
|