Skip to content

Commit

Permalink
Fix "Parameter #1 $numberToParse of method libphonenumber\PhoneNumber…
Browse files Browse the repository at this point in the history
…Util::parse() expects string, string|null given".
  • Loading branch information
rvdsteege committed Oct 18, 2024
1 parent 170252d commit b783be0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/AddressTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,18 @@ public function transform_wp_to_mollie( WordPressAddress $address ): MollieAddre

$mollie_address = new MollieAddress( $given_name, $family_name, $email, $street_and_number, $city, $country );

$phone_util = PhoneNumberUtil::getInstance();
$phone = $address->get_phone();

$phone_number_object = $phone_util->parse( $address->get_phone(), $country );
if ( null !== $phone ) {
$phone_util = PhoneNumberUtil::getInstance();

$phone_number_object = $phone_util->parse( $phone, $country );

$phone = $phone_util->format( $phone_number_object, PhoneNumberFormat::E164 );
}

$mollie_address->organization_name = $address->get_company_name();
$mollie_address->phone = $phone_util->format( $phone_number_object, PhoneNumberFormat::E164 );
$mollie_address->phone = $phone;
$mollie_address->street_additional = $address->get_line_2();
$mollie_address->postal_code = $address->get_postal_code();
$mollie_address->region = $address->get_region();
Expand Down

0 comments on commit b783be0

Please sign in to comment.