| 1 |
<?php |
| 2 |
|
| 3 |
namespace Give\Donations\Properties; |
| 4 |
|
| 5 |
use Give\Framework\Support\Contracts\Arrayable; |
| 6 |
use JsonSerializable; |
| 7 |
|
| 8 |
/** |
| 9 |
* @since 3.20.0 added JsonSerializable an Arrayable |
| 10 |
* @since 2.19.6 |
| 11 |
*/ |
| 12 |
final class BillingAddress implements JsonSerializable, Arrayable |
| 13 |
{ |
| 14 |
/** |
| 15 |
* @var string |
| 16 |
*/ |
| 17 |
public $country; |
| 18 |
/** |
| 19 |
* @var string |
| 20 |
*/ |
| 21 |
public $address1; |
| 22 |
/** |
| 23 |
* @var string |
| 24 |
*/ |
| 25 |
public $address2; |
| 26 |
/** |
| 27 |
* @var string |
| 28 |
*/ |
| 29 |
public $city; |
| 30 |
/** |
| 31 |
* @var string |
| 32 |
*/ |
| 33 |
public $state; |
| 34 |
/** |
| 35 |
* @var string |
| 36 |
*/ |
| 37 |
public $zip; |
| 38 |
|
| 39 |
/** |
| 40 |
* @since 2.19.6 |
| 41 |
* |
| 42 |
* @param array $array |
| 43 |
* |
| 44 |
* @return BillingAddress |
| 45 |
*/ |
| 46 |
public static function fromArray($array) |
| 47 |
{ |
| 48 |
$self = new static(); |
| 49 |
|
| 50 |
$self->country = $array['country']; |
| 51 |
$self->address1 = $array['address1']; |
| 52 |
$self->address2 = $array['address2']; |
| 53 |
$self->city = $array['city']; |
| 54 |
$self->state = $array['state']; |
| 55 |
$self->zip = $array['zip']; |
| 56 |
|
| 57 |
return $self; |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* @since 3.20.0 |
| 62 |
*/ |
| 63 |
public function toArray(): array |
| 64 |
{ |
| 65 |
return [ |
| 66 |
'country' => $this->country, |
| 67 |
'address1' => $this->address1, |
| 68 |
'address2' => $this->address2, |
| 69 |
'city' => $this->city, |
| 70 |
'state' => $this->state, |
| 71 |
'zip' => $this->zip, |
| 72 |
]; |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* @since 3.20.0 |
| 77 |
*/ |
| 78 |
#[\ReturnTypeWillChange] |
| 79 |
public function jsonSerialize() |
| 80 |
{ |
| 81 |
return $this->toArray(); |
| 82 |
} |
| 83 |
} |
| 84 |
|