Add PostgreSQL Support (#3)
Reviewed-on: #3
This commit was merged in pull request #3.
This commit is contained in:
@@ -41,11 +41,12 @@ enum AutoId
|
||||
/**
|
||||
* Generate a random string ID
|
||||
*
|
||||
* @param int|null $length The length of string to generate (optional; defaults to configured ID string length)
|
||||
* @return string A string filled with the hexadecimal representation of random bytes
|
||||
* @throws RandomException If an appropriate source of randomness cannot be found
|
||||
*/
|
||||
public static function generateRandom(): string
|
||||
public static function generateRandom(?int $length = null): string
|
||||
{
|
||||
return bin2hex(random_bytes(Configuration::$idStringLength / 2));
|
||||
return bin2hex(random_bytes(($length ?? Configuration::$idStringLength) / 2));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user