Refactor conditionals

This commit is contained in:
Emili Castells Guasch 2025-08-08 15:05:43 +02:00
parent e1c8b223d2
commit f93cfaa3e1
No known key found for this signature in database

View file

@ -98,20 +98,15 @@ class ShippingFactory {
public function from_paypal_response( \stdClass $data ): Shipping {
$name = $data->name->full_name ?? null;
$address = null;
if ( isset( $data->address ) ) {
$address = $this->address_factory->from_paypal_response( $data->address );
}
$address = isset( $data->address )
? $this->address_factory->from_paypal_response( $data->address )
: null;
$contact_email = null;
if ( isset( $data->email_address ) ) {
$contact_email = $data->email_address;
}
$contact_email = $data->email_address ?? null;
$contact_phone = null;
if ( isset( $data->phone_number->national_number ) ) {
$contact_phone = new Phone( $data->phone_number->national_number );
}
$contact_phone = isset( $data->phone_number->national_number )
? new Phone( $data->phone_number->national_number )
: null;
$options = array_map(
array( $this->shipping_option_factory, 'from_paypal_response' ),