Files
webman-buildadmin/app/common/library/MalaysiaMobilePhone.php
zhenhui e65c3474bd 1.修改电话号码格式为60前缀,马来西亚格式
2.优化渠道可以查看分红方式,可以查看游玩详情
2026-05-30 11:09:54 +08:00

30 lines
692 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
namespace app\common\library;
/**
* 马来西亚手机号60 国际前缀,不含 +
*/
class MalaysiaMobilePhone
{
public const PATTERN = '/^60(1[0-9])\d{7,9}$/';
public static function isValid(string $phone): bool
{
return $phone !== '' && preg_match(self::PATTERN, $phone) === 1;
}
public static function maskInNickname(string $text): string
{
$masked = preg_replace_callback(
self::PATTERN,
static fn(array $matches): string => substr($matches[0], 0, 3) . '****' . substr($matches[0], -4),
$text
);
return is_string($masked) ? $masked : $text;
}
}