当前位置: 首页>>代码示例>>PHP>>正文


PHP Uuid::uuid5方法代码示例

本文整理汇总了PHP中Ramsey\Uuid\Uuid::uuid5方法的典型用法代码示例。如果您正苦于以下问题:PHP Uuid::uuid5方法的具体用法?PHP Uuid::uuid5怎么用?PHP Uuid::uuid5使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ramsey\Uuid\Uuid的用法示例。


在下文中一共展示了Uuid::uuid5方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
     }
 }
开发者ID:transformatika,项目名称:utility,代码行数:29,代码来源:Str.php

示例2: createUuid

 /**
  * @return mixed
  * @throws \Exception
  */
 public function createUuid()
 {
     if (!$this->getInstanceIdentifier()) {
         throw new \Exception("No instance identifier specified.");
     }
     $uuid = \Ramsey\Uuid\Uuid::uuid5(\Ramsey\Uuid\Uuid::NAMESPACE_DNS, $this->getInstanceIdentifier());
     return $uuid;
 }
开发者ID:tododo,项目名称:pimcore,代码行数:12,代码来源:UUID.php

示例3: stub

 /**
  * Quick way to set variables for a new lease.
  *
  * @param $resourceId
  * @param null $userId
  * @param null $duration
  * @return array
  */
 public static function stub($resourceId, $userId = null, $duration = null)
 {
     $duration = is_null($duration) ? 60 : $duration;
     $userId = is_null($userId) ? Auth::user()->id : $userId;
     $leaseParams = ['resource_id' => $resourceId, 'user_id' => $userId, 'duration' => $duration, 'expires_at' => Carbon::create()->addMinutes($duration)];
     $leaseParams['uuid'] = Uuid::uuid5(Uuid::NAMESPACE_DNS, $leaseParams['resource_id'] . $leaseParams['user_id']);
     return $leaseParams;
 }
开发者ID:ryan215,项目名称:Learning-Laravel-5,代码行数:16,代码来源:Lease.php

示例4: bootUuidModel

 /**
  * Registering uuid listeners
  */
 public static function bootUuidModel()
 {
     static::creating(function ($model) {
         $model->uuid = Uuid::uuid5(Uuid::NAMESPACE_DNS, sprintf('%s.%s.%s.%s', rand(0, time()), time(), static::class, config('modelutils.namespace')))->toString();
     });
     static::saving(function ($model) {
         $originalUuid = $model->getOriginal('uuid');
         // Preventing lateral modifying uuid
         if ($originalUuid !== $model->uuid) {
             $model->uuid = $originalUuid;
         }
     });
 }
开发者ID:beautycoding,项目名称:modelutils,代码行数:16,代码来源:UuidModel.php

示例5: generateV5

 /**
  * Generates a v5 UUID.
  *
  * @param string $str
  *   The word to generate the UUID with.
  * @param string $namespace
  *   A namespace
  * @return String   Valid v5 UUID.
  */
 public function generateV5($str, $namespace = NULL)
 {
     // Use default namespace if none is provided.
     if (!empty($namespace)) {
         // Is this a UUID already?
         if (Uuid::isValid($namespace)) {
             return Uuid::uuid5($namespace, $str)->toString();
         } else {
             return Uuid::uuid5(Uuid::uuid5(Uuid::NAMESPACE_DNS, $namespace), $str)->toString();
         }
     } else {
         return Uuid::uuid5($this->namespace, $str)->toString();
     }
 }
开发者ID:mark-cooper,项目名称:chullo,代码行数:23,代码来源:UuidGenerator.php

示例6: generateGuid

 public static function generateGuid($reference = null)
 {
     if (isset($reference)) {
         $uuid = Uuid::uuid5(Uuid::NAMESPACE_OID, $reference);
     } else {
         $uuid = Uuid::uuid4();
     }
     return '{' . $uuid->toString() . '}';
 }
开发者ID:zaporylie,项目名称:php-frontsystems,代码行数:9,代码来源:Sale.php

示例7: getCacheKey

 /**
  * Unique cache key for this Container.
  *
  * @return string
  */
 public function getCacheKey()
 {
     //Return Key
     return 'PersonalityInsights-' . Uuid::uuid5(Uuid::NAMESPACE_DNS, collect(['contentItems' => $this->toArray()])->toJson())->toString();
 }
开发者ID:findbrok,项目名称:laravel-personality-insights,代码行数:10,代码来源:ContentListContainer.php

示例8: generateUuid5

 /**
  * @param string $namespace
  * @param string $name
  *
  * @return $this
  */
 public function generateUuid5($namespace, $name)
 {
     $this->uuid = Uuid::uuid5($namespace, $name);
     return $this;
 }
开发者ID:scr-be,项目名称:arthur-doctrine-entity-traits-library,代码行数:11,代码来源:UuidMutableTrait.php

示例9: calculateUuid

 /**
  * Calculates a UUID for a passed string.
  *
  * @param string $input The input to calculate the UUID for.
  *
  * @author Benjamin Carl <opensource@clickalicious.de>
  *
  * @return string The UUID
  */
 protected function calculateUuid($input)
 {
     try {
         // Generate a version 5 (name-based and hashed with SHA1) UUID object
         $uuid5 = Uuid::uuid5(Uuid::NAMESPACE_DNS, $input);
         $uuid = $uuid5->toString();
     } catch (UnsatisfiedDependencyException $e) {
         $uuid = sha1($input);
     }
     return $uuid;
 }
开发者ID:clickalicious,项目名称:doozr,代码行数:20,代码来源:Route.php

示例10: uuid

 /**
  * Generate and return a UUID.
  *
  * If the $name parameter is provided, set the namespace to the provided
  * name and generate a UUID.
  *
  * @param string $name
  * @return string
  */
 public function uuid($name = null)
 {
     if (is_null($name)) {
         $uuid = Uuid::uuid4();
     } else {
         if (stristr($name, 'http') == false) {
             $uuid = Uuid::uuid5(Uuid::NAMESPACE_DNS, $name);
         } else {
             $uuid = Uuid::uuid5(Uuid::NAMESPACE_URL, $name);
         }
     }
     return $this->encode($uuid);
 }
开发者ID:pyyoshi,项目名称:shortuuid-php,代码行数:22,代码来源:ShortUUID.php

示例11: testShouldAcceptUuid5

 public function testShouldAcceptUuid5()
 {
     $uuid = new Uuid(BaseUuid::uuid5(BaseUuid::NAMESPACE_DNS, 'user'));
     $this->assertInstanceOf('App\\Domain\\Identity\\Uuid', $uuid);
 }
开发者ID:xtreamwayz,项目名称:zend-expressive-app-poc,代码行数:5,代码来源:UuidTest.php

示例12: v5

 /**
  * UUID v5 generator.
  *
  * @since 150424 Initial release.
  *
  * @param string $namespace  Namespace.
  * @param string $identifier Identifier.
  * @param bool   $optimize   Optimize?
  *
  * @return string Version 5 UUID (32 bytes optimized).
  *                Or 36 bytes unoptimized; i.e., w/ dashes.
  */
 public function v5(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:
             throw $this->c::issue('Invalid namespace.');
     }
     $uuid = UuidGen::uuid5($namespace, $identifier)->toString();
     return $optimize ? str_replace('-', '', $uuid) : $uuid;
 }
开发者ID:websharks,项目名称:core,代码行数:41,代码来源:Uuid.php

示例13: 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)));
 }
开发者ID:gbprod,项目名称:uuid-normalizer,代码行数:4,代码来源:UuidNormalizerTest.php

示例14: pageId

 /**
  * Generates a hash based on page identifier
  *
  * @param string $identifier
  * @param null|integer $id
  * @return string
  */
 private static function pageId($identifier, $id = null)
 {
     $uuid5 = Uuid::uuid5(Uuid::NAMESPACE_DNS, $identifier);
     if ($id) {
         $uuid5 = Uuid::uuid5(Uuid::NAMESPACE_DNS, $identifier . '-' . $id);
     }
     return $uuid5;
 }
开发者ID:kryptonit3,项目名称:counter,代码行数:15,代码来源:Counter.php

示例15: 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:ramsey,项目名称:uuid-console,代码行数:34,代码来源:GenerateCommand.php


注:本文中的Ramsey\Uuid\Uuid::uuid5方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。