function PeclUuidNameGenerator::generate
@psalm-pure
Overrides NameGeneratorInterface::generate
File
-
vendor/
ramsey/ uuid/ src/ Generator/ PeclUuidNameGenerator.php, line 34
Class
- PeclUuidNameGenerator
- PeclUuidNameGenerator generates strings of binary data from a namespace and a name, using ext-uuid
Namespace
Ramsey\Uuid\GeneratorCode
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm) : string {
$uuid = match ($hashAlgorithm) { 'md5' => uuid_generate_md5($ns->toString(), $name),
'sha1' => uuid_generate_sha1($ns->toString(), $name),
default => throw new NameException(sprintf('Unable to hash namespace and name with algorithm \'%s\'', $hashAlgorithm)),
};
return uuid_parse($uuid);
}