diff --git a/application/Espo/Core/Fields/Address.php b/application/Espo/Core/Fields/Address.php index 50f60ca7a1..33f6b127d4 100644 --- a/application/Espo/Core/Fields/Address.php +++ b/application/Espo/Core/Fields/Address.php @@ -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. */ diff --git a/application/Espo/Core/Fields/Address/AddressBuilder.php b/application/Espo/Core/Fields/Address/AddressBuilder.php index 3a6549fdc9..13e770b841 100644 --- a/application/Espo/Core/Fields/Address/AddressBuilder.php +++ b/application/Espo/Core/Fields/Address/AddressBuilder.php @@ -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 + ); } }