Skip to content

Commit 18197cc

Browse files
committed
Cleanup: Store number of total digits
1 parent 0449039 commit 18197cc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Generator/Passcode.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ class Passcode
1414
public const DEFAULT_LENGTH = 6;
1515

1616
private const DIGITS = '1234567890';
17+
private const TOTAL_DIGITS = 9;
1718

1819
public static function generate(int $length = self::DEFAULT_LENGTH): string
1920
{
2021
$code = [];
2122
for ($amount = 0; $amount < $length; $amount++) {
22-
$code[] = self::DIGITS[mt_rand(0, 9)];
23+
$code[] = self::DIGITS[mt_rand(0, self::TOTAL_DIGITS)];
2324
}
2425

2526
return implode($code);

0 commit comments

Comments
 (0)