| 1 |
<?php |
| 2 |
/** |
| 3 |
* Internet Faker Class |
| 4 |
* |
| 5 |
* @package Timetics |
| 6 |
*/ |
| 7 |
namespace Timetics\Core\DummyData\Provider; |
| 8 |
|
| 9 |
/** |
| 10 |
* Internet Faker Class |
| 11 |
*/ |
| 12 |
class Internet { |
| 13 |
/** |
| 14 |
* Store Internet Free Domain |
| 15 |
* |
| 16 |
* @var array |
| 17 |
*/ |
| 18 |
protected static $domains = ['gmail.com', 'yahoo.com', 'hotmail.com']; |
| 19 |
|
| 20 |
/** |
| 21 |
* Store random character |
| 22 |
* |
| 23 |
* @var string |
| 24 |
*/ |
| 25 |
protected static $str = 'abcdefghijklmnopqrstuvwxyz12345_-.'; |
| 26 |
|
| 27 |
/** |
| 28 |
* Get username |
| 29 |
* |
| 30 |
* @return string |
| 31 |
*/ |
| 32 |
public static function username() { |
| 33 |
$strLength = strlen( self::$str ); |
| 34 |
|
| 35 |
// Generate a random start position within the valid range |
| 36 |
$start_pos = mt_rand( 0, max( 0, $strLength - 5 ) ); |
| 37 |
|
| 38 |
// Extract the random substring using substr() |
| 39 |
$random_substring = substr( self::$str, $start_pos, 5 ); |
| 40 |
|
| 41 |
return $random_substring . '_' . time(); |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Get generated email |
| 46 |
* |
| 47 |
* @return string |
| 48 |
*/ |
| 49 |
public static function email() { |
| 50 |
$email = self::username() . '@' . self::domain(); |
| 51 |
|
| 52 |
return $email; |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Get generated password |
| 57 |
* |
| 58 |
* @return string |
| 59 |
*/ |
| 60 |
public static function password() { |
| 61 |
$password = uniqid() . '_' . time(); |
| 62 |
|
| 63 |
return $password; |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Get domain name |
| 68 |
* |
| 69 |
* @return string |
| 70 |
*/ |
| 71 |
private static function domain() { |
| 72 |
return self::$domains[array_rand( self::$domains )]; |
| 73 |
} |
| 74 |
} |
| 75 |
|