Skip to content

Commit

Permalink
refactor AddressFormatter.php
Browse files Browse the repository at this point in the history
  • Loading branch information
vegimcarkaxhija committed Nov 21, 2024
1 parent 997183a commit 728162f
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions Service/Formatter/AddressFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,38 @@ public function __construct(
}

/**
* @param OrderAddressInterface $address
* Formats the address into a structured array.
*
* @param OrderAddressInterface $address
* @return array
*/
public function format($address)
public function format(OrderAddressInterface $address): array
{
$formattedAddress = [
return [
'street' => $this->formatStreet($address->getStreet()),
'telephone' => $this->formatTelephone($address->getTelephone(), $address->getCountryId())
'telephone' => $this->formatTelephone($address->getTelephone(), $address->getCountryId()),
];

return $formattedAddress;
}

/**
* @param $street
* Formats the street address.
*
* @param array|string|null $street
* @return array
*/
public function formatStreet($street)
public function formatStreet($street): array
{
return $this->streetFormatter->format($street);
}

/**
* @param $phoneNumber
* @param $country
* Formats the phone number based on the country.
*
* @param string|null $phoneNumber
* @param string $country
* @return array
*/
public function formatTelephone($phoneNumber, $country)
public function formatTelephone(?string $phoneNumber, string $country): array
{
return $this->phoneFormatter->format($phoneNumber, $country);
}
Expand Down

0 comments on commit 728162f

Please sign in to comment.