當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Uuid::uuid5方法代碼示例

本文整理匯總了PHP中Rhumsaa\Uuid\Uuid::uuid5方法的典型用法代碼示例。如果您正苦於以下問題:PHP Uuid::uuid5方法的具體用法?PHP Uuid::uuid5怎麽用?PHP Uuid::uuid5使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Rhumsaa\Uuid\Uuid的用法示例。


在下文中一共展示了Uuid::uuid5方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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());
 }
開發者ID:gponster,項目名稱:laravel-url62-uuid,代碼行數:28,代碼來源:Url62UuidGenerator.php

示例2: generateUniqueId

 /**
  * {@inheritDoc}
  */
 public function generateUniqueId($name = null)
 {
     if (empty($name)) {
         $name = uniqid($name, $moreEnthropy = true);
     }
     return RhumsaaUuid::uuid5(RhumsaaUuid::NAMESPACE_OID, $name)->toString();
 }
開發者ID:absolvent,項目名稱:php-guid,代碼行數:10,代碼來源:Uuid.php

示例3: testUuidToBinary

 public function testUuidToBinary()
 {
     $uuid = Uuid::uuid5(Uuid::NAMESPACE_OID, 1);
     $binary = UuidConverter::uuidToBinary($uuid->toString());
     $finalUuid = Uuid::fromBytes($binary);
     $this->assertSame($uuid->toString(), $finalUuid->toString());
 }
開發者ID:ellipsesynergie,項目名稱:backend-skeleton,代碼行數:7,代碼來源:UuidConverterTest.php

示例4: 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;
 }
開發者ID:tunandras,項目名稱:webtrees,代碼行數:34,代碼來源:GenerateCommand.php

示例5: testId

 public function testId()
 {
     #$id = (string)Uuid::uuid4();
     #$id = (string)Uuid::uuid5(Uuid::NAMESPACE_DNS, 'php.net');
     $key = sslKeyPubClean(static::SSL_KEY_PUB1);
     $keyBin = base64_decode($key);
     $id = (string) Uuid::uuid5(Uuid::NAMESPACE_X500, $keyBin);
     $this->assertEquals('d4773c00-6a11-540a-b72c-ed106ef8309b', $id);
     $id = (string) Uuid::uuid5(Uuid::NAMESPACE_X500, static::SSL_KEY_PUB1);
     $this->assertEquals('91a3d7b5-28fe-52d1-a56d-b09093c63c84', $id);
     $id = (string) Uuid::uuid5(Uuid::NAMESPACE_X500, 'hello world');
     $this->assertEquals('dbd9b896-6d7c-5852-895c-ecc5735cf874', $id);
     $id = (string) Uuid::uuid5(Uuid::NAMESPACE_DNS, 'hello world');
     $this->assertEquals('823a2f73-a936-56c3-b8b4-03641bd74f35', $id);
     $id = (string) Uuid::uuid5(Uuid::NAMESPACE_X500, 'my_name');
     $this->assertEquals('045fe53e-72be-5a76-8f58-783aed5c99d5', $id);
     $this->assertTrue(Uuid::isValid('91a3d7b5-28fe-52d1-a56d-b09093c63c84'));
     $this->assertFalse(Uuid::isValid('x1a3d7b5-28fe-52d1-a56d-b09093c63c84'));
     $id = '00000000-0000-4000-8000-000000000000';
     $this->assertTrue(Uuid::isValid($id));
     $id = '00000000-0000-4000-8000-00000000000x';
     $this->assertFalse(Uuid::isValid($id));
     $id = '00000000-0000-4000-8000-0000000000';
     $this->assertFalse(Uuid::isValid($id));
     $id = '00000000-0000-0000-0000-000000000000';
     $this->assertTrue(Uuid::isValid($id));
     $id = 'badfood0-0000-4000-a000-000000000000';
     $this->assertFalse(Uuid::isValid($id));
     $id = 'cafed00d-2131-4159-8e11-0b4dbadb1738';
     $this->assertTrue(Uuid::isValid($id));
 }
開發者ID:thefox,項目名稱:phpchat,代碼行數:31,代碼來源:UuidTest.php

示例6: testEventPublish

 public function testEventPublish()
 {
     $eventBus = new EventBus();
     $listener = new PhotoTestEventListener();
     $eventBus->subscribe($listener);
     $uuid = Uuid::uuid5(Uuid::NAMESPACE_DNS, 'photo1');
     new Photo("/some/file/path.img", $uuid->toString(), $eventBus);
     $this->assertTrue($listener->handled());
 }
開發者ID:tmciver,項目名稱:gallerylib,代碼行數:9,代碼來源:PhotoTest.php

示例7: v5

 /**
  * 基於名字的SHA-1散列值,與v3一樣,區別是使用哈希算法換了sha1
  *
  * @param  string $namespace
  * @param  string $name
  * @return string
  */
 public static function v5($namespace = VendorUUID::NAMESPACE_DNS, $name = 'php.net')
 {
     try {
         $uuid5 = VendorUUID::uuid5($namespace, $name);
         return $uuid5->toString();
     } catch (UnsatisfiedDependencyException $e) {
         return false;
     }
 }
開發者ID:tourze,項目名稱:security,代碼行數:16,代碼來源:UUID.php

示例8: getUUID5Token

 /**
  * Get token value with UUID5 string.
  *
  * @param  \App\Application $app
  * @return string|null
  */
 private function getUUID5Token(Application $app)
 {
     try {
         $uuid5 = Uuid::uuid5(Uuid::NAMESPACE_DNS, time() . $app->name . $app->type);
         return $uuid5->toString();
     } catch (UnsatisfiedDependencyException $e) {
         return null;
     }
 }
開發者ID:GreenHackers,項目名稱:election-website,代碼行數:15,代碼來源:TokenGenerationController.php

示例9: execute

 public function execute()
 {
     // see if a photo with this file path already exists in the system; do
     // nothing if it does
     // generate a uuid using the photo file path as the 'name' parameter
     $uuid = Uuid::uuid5(Uuid::NAMESPACE_DNS, $this->filePath);
     // create the photo object.  This should cause some kind of 'photo added
     // event'
     // add it to the media repository
 }
開發者ID:tmciver,項目名稱:gallerylib,代碼行數:10,代碼來源:AddPhotoCommand.php

示例10: v5

 /**
  * Create a UUID v5sudos
  *
  * @return string
  * @throws \Exception
  */
 public static function v5()
 {
     try {
         $uuid = RhumsaaUuid::uuid5(RhumsaaUuid::NAMESPACE_DNS, 'php.net');
         $uuidString = $uuid->toString();
     } catch (UnsatisfiedDependencyException $exc) {
         throw new \Exception(__METHOD__ . ': Some dependency was not met or the method cannot be called on a 32 bit
         system.', $exc);
     }
     return $uuidString;
 }
開發者ID:gdpro,項目名稱:gdpro-tool,代碼行數:17,代碼來源:UuidGenerator.php

示例11: convertUrlToUuid

 /**
  * @param $url
  * @return bool|string
  */
 public function convertUrlToUuid($url)
 {
     try {
         $urlArray = parse_url(strtolower(trim($url)));
         $urlArray['query'] = isset($urlArray['query']) ? explode("&", $urlArray['query']) : array();
         sort($urlArray['query']);
         $string = $urlArray['host'] . $urlArray['path'] . implode("", $urlArray['query']);
         $string = str_replace("/", "", $string);
         return Uuid::uuid5(Uuid::NAMESPACE_DNS, $string)->toString();
     } catch (UnsatisfiedDependencyException $e) {
         return false;
     }
 }
開發者ID:areinert,項目名稱:metador2,代碼行數:17,代碼來源:WmsImport.php

示例12: create

 /**
  * Create a model.
  * 
  * @param type $model
  * @return void
  * @throws \Exception
  */
 public function create(AbstractModel $model)
 {
     $currentTime = time();
     if ($model->getId() === null) {
         $uuid = (string) Uuid::uuid5(Uuid::NAMESPACE_DNS, uniqid('', true));
         $model->setId($uuid);
     }
     if ($model->getDateCreated() === null) {
         $model->setDateCreated($currentTime);
     }
     $model->setDateLastUpdated($currentTime);
     // Loop over each of the write strategies executing the create method.
     $this->writeDataChange($model, self::METHOD_CREATE);
 }
開發者ID:blockjon,項目名稱:octopus,代碼行數:21,代碼來源:AbstractDAO.php

示例13: createPlan

 public function createPlan(array $plan)
 {
     $em = $this->doctrineBoot->getEntityManager();
     $id = Uuid::uuid5(Uuid::NAMESPACE_OID, $plan['name'])->toString();
     $repo = $em->getRepository(Plan::class);
     $planObject = $repo->find($id);
     $free = !isset($service['free']) || $service['free'] ? true : false;
     if ($planObject === null) {
         $planObject = new Plan($id, $plan['name'], $plan['description']);
     }
     if (isset($plan['metadata'])) {
         $planObject->setMetadata($this->createMetadata($plan['metadata']));
     }
     $planObject->setFree($free);
     $em->persist($planObject);
     return $planObject;
 }
開發者ID:cloudfoundry-community,項目名稱:php-cf-service-broker,代碼行數:17,代碼來源:ServiceDescribeCreator.php

示例14: run

 /**
  * Run seeder
  */
 public function run()
 {
     $accounts = [['uuid' => UuidConverter::uuidToBinary(Uuid::uuid5(Uuid::NAMESPACE_OID, 'account_1')->toString()), 'owner_id' => 1, 'custom_domain' => null, 'name' => 'Account 1', 'slug' => 'account', 'language' => 'en', 'timezone' => 'America/Toronto', 'created_at' => Carbon::now()->subDays(365)]];
     DB::table('accounts')->insert($accounts);
 }
開發者ID:ellipsesynergie,項目名稱:backend-skeleton,代碼行數:8,代碼來源:AccountTableSeeder.php

示例15: uuid5

 public static function uuid5($ns, $name)
 {
     return BaseUuid::uuid5($ns, $name);
 }
開發者ID:kpacha,項目名稱:sifo-uuid-plugin,代碼行數:4,代碼來源:Uuid.php


注:本文中的Rhumsaa\Uuid\Uuid::uuid5方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。