本文整理汇总了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);
}
示例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);
});
}
示例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;
}
}
示例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);
}
示例5: key
/**
* Obtain the session key.
*
* For this adapter, it is a UUID.
*
* @return string UUID.
*/
public static function key()
{
return String::uuid();
}
示例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;
}