Address.php
5 years ago
Color.php
5 years ago
Company.php
5 years ago
DateTime.php
5 years ago
Internet.php
5 years ago
Payment.php
5 years ago
Person.php
5 years ago
PhoneNumber.php
5 years ago
PhoneNumber.php
24 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Faker\Provider\zh_CN; |
| 4 | |
| 5 | class PhoneNumber extends \Faker\Provider\PhoneNumber |
| 6 | { |
| 7 | protected static $operators = array( |
| 8 | 134, 135, 136, 137, 138, 139, 147, 150, 151, 152, 157, 158, 159, 1705, 178, 182, 183, 184, 187, 188, // China Mobile |
| 9 | 130, 131, 132, 145, 155, 156, 1707, 1708, 1709, 1718, 1719, 176, 185, 186, // China Unicom |
| 10 | 133, 153, 1700, 1701, 177, 180, 181, 189, // China Telecom |
| 11 | 170, 171, // virtual operators |
| 12 | ); |
| 13 | |
| 14 | protected static $formats = array('###########'); |
| 15 | |
| 16 | public function phoneNumber() |
| 17 | { |
| 18 | $operator = static::randomElement(static::$operators); |
| 19 | $format = static::randomElement(static::$formats); |
| 20 | |
| 21 | return $operator . static::numerify(substr($format, 0, strlen($format) - strlen($operator))); |
| 22 | } |
| 23 | } |
| 24 |