1 | <?php |
||
15 | class RandomString |
||
16 | { |
||
17 | |||
18 | /** |
||
19 | * ISO Characters |
||
20 | * |
||
21 | * @final |
||
22 | * |
||
23 | */ |
||
24 | const ISO = 1; |
||
25 | |||
26 | /** |
||
27 | * ASCII Characters |
||
28 | * |
||
29 | * @final |
||
30 | * |
||
31 | */ |
||
32 | const ASCII = 2; |
||
33 | |||
34 | /** |
||
35 | * Generate a random string with specific length |
||
36 | * |
||
37 | * @param number $length |
||
38 | * The length of string to generate |
||
39 | * @param int $allowed |
||
40 | * Type of allowed characters |
||
41 | * @param boolean $repeatable |
||
42 | * Whether a character may be reused |
||
43 | * |
||
44 | * @return string The generated string |
||
45 | */ |
||
46 | 3 | public static function generate($length = 8, $allowed = RandomString::ASCII, $repeatable = true): string |
|
80 | |||
81 | /** |
||
82 | * Reset the locale settings back to saved vars |
||
83 | * |
||
84 | * @param string $localeSaved |
||
85 | * String containing the locale infos obtained using setlocale(LC_ALL, ''); |
||
86 | */ |
||
87 | 3 | private static function resetLocaleTo($localeSaved) |
|
132 | } |
||
133 |