From 82baef50ee8db0254f40a073349be94f6470a04d Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Mon, 4 May 2020 11:30:43 +0800 Subject: [PATCH] Make checks for mobile number format #394 --- src/Command/WarrantySMSCommand.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Command/WarrantySMSCommand.php b/src/Command/WarrantySMSCommand.php index 3e8591aa..8e0f9fc0 100644 --- a/src/Command/WarrantySMSCommand.php +++ b/src/Command/WarrantySMSCommand.php @@ -45,7 +45,26 @@ class WarrantySMSCommand extends Command foreach ($warrs as $w) { - error_log($w->getID()); + error_log($w->getID() . ' - ' . $w->getMobileNumber()); + // check valid number + $num = trim($w->getMobileNumber()); + + // should start with '9' + if ($num[0] != '9') + continue; + + // should be 10 digits + if (strlen($num) != 10) + continue; + + // should be numeric + if (!is_numeric($num)) + continue; + + error_log('valid!'); + + // add 63 prefix + $num = '63' . $num; } /*