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