This commit is contained in:
Yuri Kuznetsov
2023-03-20 13:36:50 +02:00
parent b4d02130fb
commit b85f60b855
2 changed files with 15 additions and 35 deletions
+11 -33
View File
@@ -38,25 +38,13 @@ use Espo\Core\Field\Address\AddressBuilder;
*/
class Address
{
private $street = null;
private $city = null;
private $country = null;
private $state = null;
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;
}
private ?string $country = null,
private ?string $state = null,
private ?string $city = null,
private ?string $street = null,
private ?string $postalCode = null
) {}
/**
* Whether has a street.
@@ -143,12 +131,10 @@ class Address
*/
public function withStreet(?string $street): self
{
$newAddress = self::createBuilder()
return self::createBuilder()
->clone($this)
->setStreet($street)
->build();
return $newAddress;
}
/**
@@ -156,12 +142,10 @@ class Address
*/
public function withCity(?string $city): self
{
$newAddress = self::createBuilder()
return self::createBuilder()
->clone($this)
->setCity($city)
->build();
return $newAddress;
}
/**
@@ -169,12 +153,10 @@ class Address
*/
public function withCountry(?string $country): self
{
$newAddress = self::createBuilder()
return self::createBuilder()
->clone($this)
->setCountry($country)
->build();
return $newAddress;
}
/**
@@ -182,12 +164,10 @@ class Address
*/
public function withState(?string $state): self
{
$newAddress = self::createBuilder()
return self::createBuilder()
->clone($this)
->setState($state)
->build();
return $newAddress;
}
/**
@@ -195,12 +175,10 @@ class Address
*/
public function withPostalCode(?string $postalCode): self
{
$newAddress = self::createBuilder()
return self::createBuilder()
->clone($this)
->setPostalCode($postalCode)
->build();
return $newAddress;
}
/**
+4 -2
View File
@@ -45,7 +45,8 @@ class Currency
private string $code;
/**
* @param string|float $amount
* @param string|float $amount An amount.
* @param string $code A currency code.
* @throws RuntimeException
*/
public function __construct($amount, string $code)
@@ -195,7 +196,8 @@ class Currency
/**
* Create from an amount and code.
*
* @param string|float $amount
* @param string|float $amount An amount.
* @param string $code A currency code.
* @throws RuntimeException
*/
public static function create($amount, string $code): self