From f93cfaa3e123fc6ad731bfe5cd6d0c397b57c4f8 Mon Sep 17 00:00:00 2001 From: Emili Castells Guasch Date: Fri, 8 Aug 2025 15:05:43 +0200 Subject: [PATCH] Refactor conditionals --- .../src/Factory/ShippingFactory.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/modules/ppcp-api-client/src/Factory/ShippingFactory.php b/modules/ppcp-api-client/src/Factory/ShippingFactory.php index 197fd41e9..0728d9d80 100644 --- a/modules/ppcp-api-client/src/Factory/ShippingFactory.php +++ b/modules/ppcp-api-client/src/Factory/ShippingFactory.php @@ -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' ),