= 9 && strlen($digits) <= 10) { // Mobile number typed without the leading 0: 12-345 6789. $digits = '60'.$digits; } // Anything else must already carry Malaysia's country code (60). Other countries are refused. return preg_match('/^60[1-9][0-9]{7,9}$/', $digits) === 1 ? $digits : null; } /** * A WhatsApp chat link, optionally with a message already typed in. */ public static function whatsappLink(string $number, ?string $text = null): string { return 'https://wa.me/'.$number.($text !== null ? '?text='.rawurlencode($text) : ''); } }