本文整理汇总了PHP中Ramsey\Uuid\Uuid::uuid3方法的典型用法代码示例。如果您正苦于以下问题:PHP Uuid::uuid3方法的具体用法?PHP Uuid::uuid3怎么用?PHP Uuid::uuid3使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ramsey\Uuid\Uuid
的用法示例。
在下文中一共展示了Uuid::uuid3方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateId
/**
* Generate ID
* @return String
*/
public function generateId($version = 4, $includeDash = false)
{
try {
switch ($version) {
case 1:
$uuid = Uuid::uuid1();
break;
case 3:
$uuid = Uuid::uuid3(Uuid::NAMESPACE_DNS, php_uname('n'));
break;
case 5:
$uuid = Uuid::uuid5(Uuid::NAMESPACE_DNS, php_uname('n'));
break;
default:
$uuid = Uuid::uuid4();
break;
}
return $includeDash ? $uuid->toString() : str_replace('-', '', $uuid->toString());
} catch (UnsatisfiedDependencyException $e) {
// Some dependency was not met. Either the method cannot be called on a
// 32-bit system, or it can, but it relies on Moontoast\Math to be present.
echo 'Caught exception: ' . $e->getMessage() . "\n";
exit;
}
}
示例2: generateFromString
/**
* @param $string
*
* @return string
*
* @throws UUIDGeneratorException
*/
public function generateFromString($string)
{
try {
return Uuid::uuid3(Uuid::NAMESPACE_OID, $string)->toString();
} catch (UnsatisfiedDependencyException $e) {
throw new UUIDGeneratorException($e->getMessage());
}
}
示例3: boot
protected static function boot()
{
parent::boot();
self::creating(function ($registro) {
$uuid = Uuid::uuid3(Uuid::NAMESPACE_DNS, $registro->title_oaca);
// name-based uuid
$registro->id = $uuid->toString();
return true;
});
}
示例4: uuid3
/**
* @see \Ramsey\Uuid\Uuid::uuid3()
*
* @param string $ns
* @param string $name
* @return \Ramsey\Uuid\UuidInterface
*/
public function uuid3($ns, $name)
{
return \Ramsey\Uuid\Uuid::uuid3($ns, $name);
}
示例5: v3
/**
* UUID v3 generator.
*
* @since 150424 Initial release.
*
* @param string $namespace Namespace.
* @param string $identifier Identifier.
* @param bool $optimize Optimize?
*
* @return string Version 3 UUID (32 bytes optimized).
* Or 36 bytes unoptimized; i.e., w/ dashes.
*
* @internal {@link v5()} is a suggested alternative, as this version uses MD5.
*/
public function v3(string $namespace, string $identifier, bool $optimize = true) : string
{
switch ($namespace) {
case 'dns':
$namespace = UuidGen::NAMESPACE_DNS;
break;
// Stop here.
// Stop here.
case 'url':
$namespace = UuidGen::NAMESPACE_URL;
break;
// Stop here.
// Stop here.
case 'oid':
$namespace = UuidGen::NAMESPACE_OID;
break;
// Stop here.
// Stop here.
case 'x500':
$namespace = UuidGen::NAMESPACE_X500;
break;
// Stop here.
// Stop here.
default:
$this->c::issue('Invalid namespace.');
}
$uuid = UuidGen::uuid3($namespace, $identifier)->toString();
return $optimize ? str_replace('-', '', $uuid) : $uuid;
}
示例6:
function uuid3($ns, $name)
{
$uuid = Uuid::uuid3($ns, $name);
return $uuid->toString();
}
示例7: generateUuid3
/**
* @param string $namespace
* @param string $name
*
* @return $this
*/
public function generateUuid3($namespace, $name)
{
$this->uuid = Uuid::uuid3($namespace, $name);
return $this;
}
示例8: generateUuid
/**
* Generate a uuid for the site based on it's port.
*
* @param $site
*
* @return string
*/
protected function generateUuid($site)
{
$uuid3 = Uuid::uuid3(Uuid::NAMESPACE_DNS, $site['port']);
$uuid = $uuid3->toString();
return $uuid;
}
示例9: uuid3
public static function uuid3($ns, $name)
{
return self::fromRamseyUuid(parent::uuid3($ns, $name));
}
示例10: p2uuid3
public static function p2uuid3($subDomain = self::SUBDOMAIN_UUID)
{
return Uuid::uuid3(Uuid::uuid1(), self::fullReverseDomain($subDomain));
}
示例11: uuidProvider
public function uuidProvider()
{
return array(array(Uuid::uuid1()), array(Uuid::uuid3(Uuid::NAMESPACE_DNS, 'php.net')), array(Uuid::uuid4()), array(Uuid::uuid5(Uuid::NAMESPACE_DNS, 'php.net')), array(Uuid::fromString(self::UUID_SAMPLE)));
}
示例12: 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;
}
示例13: generateUuid
/**
* Generate a uuid for the site based on it's port.
*
* @param $unique
*
* @return string
*/
public function generateUuid($unique)
{
$uuid3 = Uuid::uuid3(Uuid::NAMESPACE_DNS, $unique);
$uuid = $uuid3->toString();
return $uuid;
}
示例14: testShouldAcceptUuid3
public function testShouldAcceptUuid3()
{
$uuid = new Uuid(BaseUuid::uuid3(BaseUuid::NAMESPACE_DNS, 'user'));
$this->assertInstanceOf('App\\Domain\\Identity\\Uuid', $uuid);
}