@@ -196,7 +196,6 @@ public function __construct(
196
196
* @throws \Magento\Framework\Exception\LocalizedException
197
197
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
198
198
* @SuppressWarnings(PHPMD.NPathComplexity)
199
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
200
199
*/
201
200
public function save (CustomerInterface $ customer , $ passwordHash = null )
202
201
{
@@ -281,10 +280,7 @@ public function save(CustomerInterface $customer, $passwordHash = null)
281
280
$ savedAddressIds [] = $ address ->getId ();
282
281
}
283
282
}
284
- $ addressIdsToDelete = array_diff ($ existingAddressIds , $ savedAddressIds );
285
- foreach ($ addressIdsToDelete as $ addressId ) {
286
- $ this ->addressRepository ->deleteById ($ addressId );
287
- }
283
+ $ this ->deleteAddressesByIds (array_diff ($ existingAddressIds , $ savedAddressIds ));
288
284
}
289
285
$ this ->customerRegistry ->remove ($ customerId );
290
286
$ savedCustomer = $ this ->get ($ customer ->getEmail (), $ customer ->getWebsiteId ());
@@ -299,6 +295,19 @@ public function save(CustomerInterface $customer, $passwordHash = null)
299
295
return $ savedCustomer ;
300
296
}
301
297
298
+ /**
299
+ * Delete addresses by ids
300
+ *
301
+ * @param array $addressIds
302
+ * @return void
303
+ */
304
+ private function deleteAddressesByIds (array $ addressIds ): void
305
+ {
306
+ foreach ($ addressIds as $ id ) {
307
+ $ this ->addressRepository ->deleteById ($ id );
308
+ }
309
+ }
310
+
302
311
/**
303
312
* Validate customer group id if exist
304
313
*
0 commit comments