1.修改电话号码格式为60前缀,马来西亚格式
2.优化渠道可以查看分红方式,可以查看游玩详情
This commit is contained in:
29
app/common/library/MalaysiaMobilePhone.php
Normal file
29
app/common/library/MalaysiaMobilePhone.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user