Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PeclUuidNameGenerator.php

class PeclUuidNameGenerator

PeclUuidNameGenerator generates strings of binary data from a namespace and a name, using ext-uuid

@link https://pecl.php.net/package/uuid ext-uuid

Hierarchy

  • class \Ramsey\Uuid\Generator\PeclUuidNameGenerator implements \Ramsey\Uuid\Generator\NameGeneratorInterface

Expanded class hierarchy of PeclUuidNameGenerator

1 file declares its use of PeclUuidNameGenerator
FeatureSet.php in vendor/ramsey/uuid/src/FeatureSet.php

File

vendor/ramsey/uuid/src/Generator/PeclUuidNameGenerator.php, line 31

Namespace

Ramsey\Uuid\Generator
View source
class PeclUuidNameGenerator implements NameGeneratorInterface {
    
    /** @psalm-pure */
    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);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
PeclUuidNameGenerator::generate public function @psalm-pure Overrides NameGeneratorInterface::generate
RSS feed
Powered by Drupal