Skip to content

Commit 188d288

Browse files
committed
utilizes Random\Randomizer in PHP 8.3
1 parent 74618ab commit 188d288

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Utils/Random.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace Nette\Utils;
1111

1212
use Nette;
13+
use Random\Randomizer;
1314

1415

1516
/**
@@ -37,6 +38,8 @@ public static function generate(int $length = 10, string $charlist = '0-9a-z'):
3738
throw new Nette\InvalidArgumentException('Length must be greater than zero.');
3839
} elseif ($chLen < 2) {
3940
throw new Nette\InvalidArgumentException('Character list must contain at least two chars.');
41+
} elseif (PHP_VERSION_ID >= 80300) {
42+
return (new Randomizer)->getBytesFromString($charlist, $length);
4043
}
4144

4245
$res = '';

0 commit comments

Comments
 (0)