Skip to content

Commit

Permalink
PES-2174 CR fix
Browse files Browse the repository at this point in the history
introduce AddressProvider:: getStreet and getHouseNumber
remove redundant local variable
  • Loading branch information
Mrakor committed Jul 12, 2024
1 parent 130d58c commit 13b01c4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
9 changes: 3 additions & 6 deletions media/admin/com_virtuemart/models/zasilkovna_orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -506,25 +506,22 @@ protected function prepareForExport($orders_arr)
$ordersForExport = array();
foreach($rows as $key => $row) {
$orderForExport = array();

$address = AddressProvider::fromUserInfoArray($row);
$phone = $address->getNormalizedPhone();
list($street, $houseNumber) = array_values(AddressProvider::extractStreetAndHouseNumber($address->getAddress()));

$orderForExport['order_number'] = $row['order_number'];
$orderForExport['recipient_firstname'] = $address->getFirstName();
$orderForExport['recipient_lastname'] = $address->getLastName();
$orderForExport['recipient_company'] = "";
$orderForExport['recipient_email'] = $address->getEmail();
$orderForExport['recipient_phone'] = $phone;
$orderForExport['recipient_phone'] = $address->getNormalizedPhone();
$orderForExport['packet_cod'] = $row['packet_cod'];
$orderForExport['currency'] = $row["order_currency_name"];
$orderForExport['value'] = $row['order_total'];
$orderForExport['weight'] = $row['weight'];
$orderForExport['point_id'] = $row['branch_id'];
$orderForExport['adult_content'] = $row['adult_content'];
$orderForExport['recipient_street'] = $street;
$orderForExport['recipient_house_number'] = $houseNumber;
$orderForExport['recipient_street'] = $address->getStreet();
$orderForExport['recipient_house_number'] = $address->getHouseNumber();
$orderForExport['recipient_city'] = $address->getCity();
$orderForExport['recipient_zip'] = $address->getZip();
$orderForExport['carrier_point'] = $row['carrier_pickup_point'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ class AddressProvider
/** @var string|null */
private $address;

/** @var string|null */
private $street;

/** @var string|null */
private $houseNumber;

/** @var string|null */
private $city;

Expand All @@ -26,6 +32,8 @@ class AddressProvider
private $email;

/**
* Private constructor to force usage of factory methods
*
* @param string|null $firstName
* @param string|null $lastName
* @param string|null $address
Expand All @@ -34,7 +42,7 @@ class AddressProvider
* @param string|null $phone
* @param string|null $email
*/
public function __construct($firstName, $lastName, $address, $city, $zip, $phone, $email)
private function __construct($firstName, $lastName, $address, $city, $zip, $phone, $email)
{
$this->firstName = $firstName;
$this->lastName = $lastName;
Expand All @@ -43,6 +51,10 @@ public function __construct($firstName, $lastName, $address, $city, $zip, $phone
$this->zip = $zip;
$this->phone = $phone;
$this->email = $email;

$extracted = self::extractStreetAndHouseNumber($address);
$this->street = $extracted['street'];
$this->houseNumber = $extracted['houseNumber'];
}

/**
Expand Down Expand Up @@ -105,6 +117,22 @@ public function getAddress()
return $this->address;
}

/**
* @return string
*/
public function getStreet()
{
return $this->street;
}

/**
* @return string
*/
public function getHouseNumber()
{
return (string)$this->houseNumber;
}

/**
* @return string
*/
Expand Down

0 comments on commit 13b01c4

Please sign in to comment.