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


PHP String::uuid方法代碼示例

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


在下文中一共展示了String::uuid方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: key

 /**
  * Obtain the session key.
  *
  * For this adapter, it is a UUID based on the SERVER_ADDR variable.
  *
  * @return string UUID.
  */
 public static function key()
 {
     $context = function ($value) use(&$config) {
         return isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '127.0.0.1';
     };
     return String::uuid($context);
 }
開發者ID:EHER,項目名稱:monopolis,代碼行數:14,代碼來源:Memory.php

示例2: __init

 public static function __init()
 {
     parent::__init();
     static::applyFilter('create', function ($self, $params, $chain) {
         if (empty($params['data']['id'])) {
             $params['data']['id'] = String::uuid();
         }
         return $chain->next($self, $params, $chain);
     });
 }
開發者ID:notomato,項目名稱:li3_activitystreams,代碼行數:10,代碼來源:Base.php

示例3: testMultipleUuidGeneration

 /**
  * testMultipleUuidGeneration method
  *
  * @return void
  */
 public function testMultipleUuidGeneration()
 {
     $check = array();
     $count = 50;
     $pattern = "/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[8-9a-b][a-f0-9]{3}-[a-f0-9]{12}\$/";
     for ($i = 0; $i < $count; $i++) {
         $result = String::uuid();
         $match = preg_match($pattern, $result);
         $this->assertTrue($match);
         $this->assertFalse(in_array($result, $check));
         $check[] = $result;
     }
 }
開發者ID:newmight2015,項目名稱:Blockchain-2,代碼行數:18,代碼來源:StringTest.php

示例4: testGeneratingUuidWithCallback

 /**
  * Tests generating a UUID with seed data provided by an anonymous function.
  *
  * @return void
  */
 public function testGeneratingUuidWithCallback()
 {
     $pattern = "/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\$/";
     $result = String::uuid(function ($value) {
         if ($value == 'SERVER_ADDR') {
             return '::1';
         }
     });
     $this->assertPattern($pattern, $result);
     $result = String::uuid(function ($value) {
         if ($value == 'HOST') {
             return '127.0.0.1';
         }
     });
     $this->assertPattern($pattern, $result);
     $result = String::uuid(function ($value) {
         if ($value == 'SERVER_ADDR') {
             return '127.0.0.2';
         }
     });
     $this->assertPattern($pattern, $result);
 }
開發者ID:kdambekalns,項目名稱:framework-benchs,代碼行數:27,代碼來源:StringTest.php

示例5: key

 /**
  * Obtain the session key.
  *
  * For this adapter, it is a UUID.
  *
  * @return string UUID.
  */
 public static function key()
 {
     return String::uuid();
 }
開發者ID:nilamdoc,項目名稱:KYCGlobal,代碼行數:11,代碼來源:Memory.php

示例6: testUpdate

 public function testUpdate()
 {
     $this->_createGalleriesWithImages();
     $options = array('conditions' => array('gallery_id' => 1));
     $uuid = String::uuid();
     $image = Images::find('first', $options);
     $image->title = $uuid;
     $firstID = $image->id;
     $image->save();
     $this->assertEqual($uuid, Images::find('first', $options)->title);
     $uuid = String::uuid();
     Images::update(array('title' => $uuid), array('id' => $firstID));
     $this->assertEqual($uuid, Images::find('first', $options)->title);
     $this->images[0]['title'] = $uuid;
 }
開發者ID:davidpersson,項目名稱:FrameworkBenchmarks,代碼行數:15,代碼來源:DatabaseTest.php


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