-
Notifications
You must be signed in to change notification settings - Fork 3
/
namegen.php
55 lines (45 loc) · 1.03 KB
/
namegen.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace brytecore;
require_once "firstnames.php";
require_once "randomword.php";
require_once "adjectives.php";
/**
* Class NameGen
*
* Object to create random names using commons firstnames, adjectives and/or random fake words.
*/
class NameGen {
/**
* Generate a random first name from the most common US names.
*
* @return string
*/
function firstName() {
global $first_names;
$total = count($first_names );
$index = rand( 0, $total - 1 );
return ucfirst( strtolower($first_names[$index] ) );
}
/**
* Generate a random, non-offensive adjective.
*
* @return string
*/
function adjective() {
global $adjectives;
$total = count($adjectives);
$index = rand(0, $total - 1);
return ucfirst(strtolower($adjectives[$index]));
}
/**
* Generate a random, pronounceable word.
*
* @param int $minLength
* @param int $maxLength
*
* @return string
*/
function randomWord( $minLength = 5, $maxLength = 10) {
return ucfirst( random_pronounceable_word( rand( $minLength, $maxLength ) ) );
}
}