Add PostgreSQL Support (#3)

Reviewed-on: #3
This commit was merged in pull request #3.
This commit is contained in:
2024-06-21 13:46:41 +00:00
parent 330e272187
commit 124426fa12
61 changed files with 2290 additions and 223 deletions

View File

@@ -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));
}
}