feat: prefixes evaluables

This commit is contained in:
Nuno Maduro
2023-02-14 08:56:56 +00:00
parent 7fdc7d6997
commit 0d9c11c99a

View File

@ -15,6 +15,11 @@ final class Str
*/
private const POOL = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
/**
* @var string
*/
private const PREFIX = '__pest_evaluable_';
/**
* Create a (unsecure & non-cryptographically safe) random alpha-numeric
* string value.
@ -54,7 +59,7 @@ final class Str
*/
public static function evaluable(string $code): string
{
$code = str_replace(' ', '_', $code);
$code = self::PREFIX.str_replace(' ', '_', $code);
return (string) preg_replace('/[^A-Z_a-z0-9]/', '_', $code);
}