From 2b21db6c0119bf3ee31f88a55b6ea1a41825c353 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Thu, 21 Nov 2019 10:20:07 +0800 Subject: [PATCH] Filter valid phone numbers and convert the 09XXXXXXXXX format to 9XXXXXXXXX #274 --- src/Command/CreateCustomerFromWarrantyCommand.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Command/CreateCustomerFromWarrantyCommand.php b/src/Command/CreateCustomerFromWarrantyCommand.php index 38758990..bfac02d8 100644 --- a/src/Command/CreateCustomerFromWarrantyCommand.php +++ b/src/Command/CreateCustomerFromWarrantyCommand.php @@ -130,12 +130,26 @@ class CreateCustomerFromWarrantyCommand extends Command if (empty($w_mobile_num)) continue; + // does it fit our 09XXXXXXXXX pattern? + if (preg_match('/^09[0-9]{9}$/', $w_mobile_num)) + { + // remove first '0' + $w_mobile_num = substr($w_mobile_num, 1); + error_log("CONVERTED TO $w_mobile_num"); + } + + // does it fit our 9XXXXXXXXX pattern? + if (!preg_match('/^9[0-9]{9}$/', $w_mobile_num)) + continue; + + /* // min length 2 // TODO: we need to check proper phone number format // format should be '9XXXXXXXXX' // TODO: if format doesn't fit and there's a 0 or 63 prefix, we should be able to detect and convert if (strlen($w_mobile_num <= 2)) continue; + */ error_log(''); error_log("($total_warr) processing $w_mobile_num from warranty...");