File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 4
4
5
5
namespace Stfn \RandomString ;
6
6
7
+ use Closure ;
8
+
7
9
class StringConfig
8
10
{
9
11
const CHARSET_UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ' ;
@@ -24,7 +26,7 @@ class StringConfig
24
26
25
27
protected bool $ unique = false ;
26
28
27
- protected \ Closure |null $ skipCallback = null ;
29
+ protected Closure |null $ skipCallback = null ;
28
30
29
31
public function __construct ($ length = 16 )
30
32
{
@@ -149,7 +151,7 @@ public function hasSkipCallback(): bool
149
151
return is_callable ($ this ->skipCallback );
150
152
}
151
153
152
- public function getSkipCallback (): \ Closure |null
154
+ public function getSkipCallback (): Closure |null
153
155
{
154
156
return $ this ->skipCallback ;
155
157
}
@@ -179,7 +181,7 @@ public function isUnique(): bool
179
181
return $ this ->unique ;
180
182
}
181
183
182
- public function getCount ()
184
+ public function getCount (): int
183
185
{
184
186
return $ this ->count ;
185
187
}
Original file line number Diff line number Diff line change @@ -209,6 +209,20 @@ public function test_if_it_fails_after_max_possible_combination_reached()
209
209
$ instance ->generate ();
210
210
}
211
211
212
+ public function test_if_it_fails_when_count_is_greater_than_possible_combinations ()
213
+ {
214
+ $ config = new StringConfig ();
215
+ $ config ->length (2 )
216
+ ->count (5 )
217
+ ->unique ()
218
+ ->charset ('01 ' );
219
+
220
+ $ instance = new RandomString ($ config );
221
+
222
+ $ this ->expectException (InvalidStringConfigException::class);
223
+ $ instance ->generate ();
224
+ }
225
+
212
226
public function test_if_it_fails_after_max_possible_combination_reached_using_unique ()
213
227
{
214
228
$ config = new StringConfig ();
You can’t perform that action at this time.
0 commit comments