1 | <?php |
||
10 | class Random |
||
11 | { |
||
12 | use CharCase, |
||
13 | Faker, |
||
14 | Trivia, |
||
15 | AlphaGenerator, |
||
16 | StringGenerator, |
||
17 | IntegerGenerator; |
||
18 | |||
19 | const DEFAULT_STRING_SIZE = 16; |
||
20 | |||
21 | const DEFAULT_PATTERN = '[A-Za-z0-9]'; |
||
22 | |||
23 | protected $numeric = false; |
||
24 | |||
25 | protected $size = null; |
||
26 | |||
27 | protected $pattern = '[A-Za-z0-9]'; |
||
28 | |||
29 | private $prefix; |
||
30 | |||
31 | private $suffix; |
||
32 | |||
33 | /** |
||
34 | * Get a prefixed and/or suffixed string. |
||
35 | * |
||
36 | * @param $value |
||
37 | * @return string |
||
38 | */ |
||
39 | 12 | private function addPrefixSuffix($value) |
|
47 | |||
48 | /** |
||
49 | * Generate a random string. |
||
50 | * |
||
51 | * @return string|array |
||
52 | */ |
||
53 | 12 | protected function generate() |
|
67 | |||
68 | /** |
||
69 | * Set the string suffix. |
||
70 | * |
||
71 | * @param $string |
||
72 | * @return $this |
||
73 | */ |
||
74 | 1 | public function suffix($string) |
|
80 | |||
81 | /** |
||
82 | * Extract a string pattern from a string. |
||
83 | * |
||
84 | * @param $string |
||
85 | * @return string |
||
86 | */ |
||
87 | 10 | protected function extractPattern($string) |
|
97 | |||
98 | /** |
||
99 | * Get string pattern. |
||
100 | * |
||
101 | * @return string |
||
102 | */ |
||
103 | 10 | public function getPattern() |
|
107 | |||
108 | /** |
||
109 | * Configure to get a raw. |
||
110 | * |
||
111 | * @return string |
||
112 | */ |
||
113 | 1 | public function raw() |
|
119 | |||
120 | /** |
||
121 | * Generate a random hex. |
||
122 | * |
||
123 | * @return string |
||
124 | */ |
||
125 | 3 | public function hex() |
|
131 | |||
132 | /** |
||
133 | * Set string pattern. |
||
134 | * |
||
135 | * @param string $pattern |
||
136 | * @return $this |
||
137 | */ |
||
138 | 4 | public function pattern($pattern) |
|
144 | |||
145 | /** |
||
146 | * Set the string prefix. |
||
147 | * |
||
148 | * @param $string |
||
149 | * @return $this |
||
150 | */ |
||
151 | 2 | public function prefix($string) |
|
157 | |||
158 | /** |
||
159 | * Set result to numeric. |
||
160 | * |
||
161 | * @param bool $state |
||
162 | * @return $this |
||
163 | */ |
||
164 | 3 | public function numeric($state = true) |
|
170 | |||
171 | /** |
||
172 | * Set result to alpha. |
||
173 | * |
||
174 | * @param bool $state |
||
175 | * @return $this |
||
176 | */ |
||
177 | 1 | public function alpha($state = true) |
|
183 | |||
184 | /** |
||
185 | * Reset one-time values. |
||
186 | * |
||
187 | * @return $this |
||
188 | */ |
||
189 | 12 | public function resetOneTimeValues() |
|
199 | |||
200 | /** |
||
201 | * Get the generated random string/number. |
||
202 | * |
||
203 | * @return string|int |
||
204 | */ |
||
205 | 12 | public function get() |
|
217 | } |
||
218 |