Skip to content

Commit 13b6b19

Browse files
committed
Updated checks on setters
1 parent 08d78b6 commit 13b6b19

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

Model/PayPaymentCreate.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,27 +218,37 @@ public function getData()
218218
/**
219219
* @return \PayNL\Sdk\Model\Customer
220220
*/
221-
private function getCustomer()
221+
private function getCustomer(): \PayNL\Sdk\Model\Customer
222222
{
223223
$arrBillingAddress = $this->order->getBillingAddress();
224224

225225
$customer = new \PayNL\Sdk\Model\Customer();
226226
$customer->setFirstName(mb_substr($arrBillingAddress['firstname'] ?? '', 0, 32));
227227
$customer->setLastName(mb_substr($arrBillingAddress['lastname'] ?? '', 0, 64));
228228

229-
$customer->setIpAddress($this->getIpAddress());
229+
$customer->setIpAddress((string)$this->getIpAddress());
230230

231-
if (isset($this->additionalData['dob']) && !empty($this->additionalData['dob'])) {
232-
$customer->setBirthDate(mb_substr($this->additionalData['dob'], 0, 32));
231+
$dob = $this->additionalData['dob'] ?? null;
232+
if (!empty($dob)) {
233+
$customer->setBirthDate(mb_substr($dob, 0, 32));
233234
}
234235

235-
if (isset($this->additionalData['gender'])) {
236-
$customer->setGender(mb_substr($this->additionalData['gender'], 0, 1));
236+
$gender = $this->additionalData['gender'] ?? null;
237+
if (!empty($gender)) {
238+
$customer->setGender(mb_substr($gender, 0, 1));
237239
}
238240

239-
$customer->setPhone(payHelper::validatePhoneNumber($arrBillingAddress['telephone']));
240-
$customer->setEmail(mb_substr($arrBillingAddress['email'] ?? '', 0, 100));
241-
$customer->setLanguage($this->payConfig->getLanguage());
241+
$phone = payHelper::validatePhoneNumber($arrBillingAddress['telephone'] ?? '');
242+
if (!empty($phone)) {
243+
$customer->setPhone($phone);
244+
}
245+
246+
$email = $arrBillingAddress['email'] ?? null;
247+
if (!empty($email)) {
248+
$customer->setEmail(mb_substr($email, 0, 100));
249+
}
250+
251+
$customer->setLanguage((string)$this->payConfig->getLanguage());
242252

243253
return $customer;
244254
}
@@ -424,7 +434,7 @@ public function getDescription($orderId = null)
424434
}
425435

426436
/**
427-
* @return float|string|null
437+
* @return float|mixed|string|null
428438
*/
429439
private function getIpAddress()
430440
{

0 commit comments

Comments
 (0)