本文整理汇总了PHP中Rhumsaa\Uuid\Uuid::uuid3方法的典型用法代码示例。如果您正苦于以下问题:PHP Uuid::uuid3方法的具体用法?PHP Uuid::uuid3怎么用?PHP Uuid::uuid3使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rhumsaa\Uuid\Uuid
的用法示例。
在下文中一共展示了Uuid::uuid3方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
public static function generate($ver = 4, $node = null, $clockSeq = null, $ns = null, $name = null)
{
$uuid = null;
/* Create a new UUID based on provided data. */
switch ((int) $ver) {
case 1:
$uuid = Uuid::uuid1($node, $clockSeq);
break;
case 2:
// Version 2 is not supported
throw new \RuntimeException('UUID version 2 is unsupported.');
case 3:
$uuid = Uuid::uuid3($ns, $name);
break;
case 4:
$uuid = Uuid::uuid4();
break;
case 5:
$uuid = Uuid::uuid5($ns, $name);
break;
default:
throw new \RuntimeException('Selected UUID version is invalid or unsupported.');
}
if (function_exists('gmp_strval')) {
return gmp_strval(gmp_init($uuid->getHex(), 16), 62);
}
return Base62::encode((string) $uuid->getInteger());
}
示例2: createUuid
/**
* Creates the requested UUID
*
* @param int $version
* @param string $namespace
* @param string $name
* @return Uuid
*/
protected function createUuid($version, $namespace = null, $name = null)
{
switch ((int) $version) {
case 1:
$uuid = Uuid::uuid1();
break;
case 4:
$uuid = Uuid::uuid4();
break;
case 3:
case 5:
$ns = $this->validateNamespace($namespace);
if (empty($name)) {
throw new Exception('The name argument is required for version 3 or 5 UUIDs');
}
if ($version == 3) {
$uuid = Uuid::uuid3($ns, $name);
} else {
$uuid = Uuid::uuid5($ns, $name);
}
break;
default:
throw new Exception('Invalid UUID version. Supported are version "1", "3", "4", and "5".');
}
return $uuid;
}
示例3: v3
/**
* 基于名字的MD5散列值
* [!!] 同一命名空间的同一名字会生成相同的uuid
*
* @param VendorUUID|string $namespace
* @param string $name
* @return string
*/
public static function v3($namespace = VendorUUID::NAMESPACE_DNS, $name = 'php.net')
{
try {
$uuid3 = VendorUUID::uuid3($namespace, $name);
return $uuid3->toString();
} catch (UnsatisfiedDependencyException $e) {
return false;
}
}
示例4: uuid3
public static function uuid3($ns, $name)
{
return BaseUuid::uuid3($ns, $name);
}
示例5: createIdVersion3
/**
* generate name base and hashed md5 uuid
*
* @param string $namespace base name
* @return string
*/
protected function createIdVersion3($namespace)
{
return Uuid::uuid3(Uuid::NAMESPACE_DNS, $namespace)->toString();
}
示例6: uuid
/**
* Generates a unique UUID string.
*
* @return string
*/
function uuid()
{
return Uuid::uuid3(Uuid::NAMESPACE_DNS, str_random())->toString();
}
示例7: uuid3
public static function uuid3($ns, $name)
{
return self::bin(BaseUuid::uuid3($ns, $name));
}
示例8:
/**
* Generate a version 3 (name-based and hashed with MD5) UUID object.
*
* @param string $ns
* @param string $name
*
* @return string
*/
function uuid3($ns, $name)
{
$uuid = Uuid::uuid3($ns, $name);
return $uuid->toString();
}