feat: toBeUUID expectation

This commit is contained in:
Thai Nguyen Hung
2023-09-05 08:25:02 +07:00
parent cc6c5bf199
commit 038fd80428
3 changed files with 56 additions and 0 deletions

View File

@ -92,4 +92,12 @@ final class Str
{
return $search === '' ? $subject : array_reverse(explode($search, $subject, 2))[0];
}
/**
* Determine if a given value is a valid UUID.
*/
public static function isUuid(string $value): bool
{
return preg_match('/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iD', $value) > 0;
}
}