mirror of
https://github.com/pestphp/pest.git
synced 2026-03-12 02:37:22 +01:00
feat: prefixes evaluables
This commit is contained in:
@ -15,6 +15,11 @@ final class Str
|
|||||||
*/
|
*/
|
||||||
private const POOL = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
private const POOL = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private const PREFIX = '__pest_evaluable_';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a (unsecure & non-cryptographically safe) random alpha-numeric
|
* Create a (unsecure & non-cryptographically safe) random alpha-numeric
|
||||||
* string value.
|
* string value.
|
||||||
@ -54,7 +59,7 @@ final class Str
|
|||||||
*/
|
*/
|
||||||
public static function evaluable(string $code): string
|
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);
|
return (string) preg_replace('/[^A-Z_a-z0-9]/', '_', $code);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user