address vo changes
This commit is contained in:
@@ -46,6 +46,20 @@ class Address
|
||||
|
||||
private $postalCode = null;
|
||||
|
||||
public function __construct(
|
||||
?string $country = null,
|
||||
?string $state = null,
|
||||
?string $city = null,
|
||||
?string $street = null,
|
||||
?string $postalCode = null
|
||||
) {
|
||||
$this->country = $country;
|
||||
$this->state = $state;
|
||||
$this->city = $city;
|
||||
$this->street = $street;
|
||||
$this->postalCode = $postalCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether has a street.
|
||||
*/
|
||||
@@ -191,22 +205,6 @@ class Address
|
||||
return $newAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a RAW data.
|
||||
*/
|
||||
public static function fromRaw(array $raw): self
|
||||
{
|
||||
$obj = new self();
|
||||
|
||||
$obj->street = $raw['street'] ?? null;
|
||||
$obj->city = $raw['city'] ?? null;
|
||||
$obj->country = $raw['country'] ?? null;
|
||||
$obj->state = $raw['state'] ?? null;
|
||||
$obj->postalCode = $raw['postalCode'] ?? null;
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an empty address.
|
||||
*/
|
||||
|
||||
@@ -94,12 +94,12 @@ class AddressBuilder
|
||||
|
||||
public function build(): Address
|
||||
{
|
||||
return Address::fromRaw([
|
||||
'street' => $this->street,
|
||||
'city' => $this->city,
|
||||
'country' => $this->country,
|
||||
'state' => $this->state,
|
||||
'postalCode' => $this->postalCode,
|
||||
]);
|
||||
return new Address(
|
||||
$this->country,
|
||||
$this->state,
|
||||
$this->city,
|
||||
$this->street,
|
||||
$this->postalCode
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user