Skip to content

Commit f43c521

Browse files
author
zhaoxiang
committed
modified 完善mock随机库
1 parent f85cf16 commit f43c521

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

application/api/controller/Miss.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Miss extends Base {
99
public function index() {
1010
$this->debug([
1111
'TpVersion' => THINK_VERSION,
12-
'Float' => StrRandom::randomDate()
12+
'Float' => StrRandom::randomPhone()
1313
]);
1414

1515
return $this->buildSuccess([

application/util/StrRandom.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,38 @@ public static function randomEmail($domain = '') {
153153

154154
}
155155

156+
157+
public static function randomPhone() {
158+
$prefixArr = [133, 153, 173, 177, 180, 181, 189, 199, 134, 135,
159+
136, 137, 138, 139, 150, 151, 152, 157, 158, 159, 172, 178,
160+
182, 183, 184, 187, 188, 198, 130, 131, 132, 155, 156, 166,
161+
175, 176, 185, 186, 145, 147, 149, 170, 171];
162+
shuffle($prefixArr);
163+
164+
return $prefixArr[0] . Strs::randString(8, 1);
165+
}
166+
167+
/**
168+
* 随机创建一个身份证号码
169+
* @return string
170+
* @author zhaoxiang <zhaoxiang051405@gmail.com>
171+
*/
172+
public static function randomId() {
173+
$prefixArr = [
174+
11, 12, 13, 14, 15,
175+
21, 22, 23,
176+
31, 32, 33, 34, 35, 36, 37,
177+
41, 42, 43, 44, 45, 46,
178+
50, 51, 52, 53, 54,
179+
61, 62, 63, 64, 65,
180+
71, 81, 82
181+
];
182+
shuffle($prefixArr);
183+
184+
$suffixArr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'X'];
185+
shuffle($suffixArr);
186+
187+
return $prefixArr[0] . '0000' . self::randomDate('Ymd') . Strs::randString(3, 1) . $suffixArr[0];
188+
}
189+
156190
}

0 commit comments

Comments
 (0)