eve/uuid

eve 简单的 Ramsey UUID 封装器

维护者

详细信息

github.com/Eveio/uuid

源代码

v1.0.0 2020-11-26 12:05 UTC

This package is auto-updated.

Last update: 2024-08-26 20:53:37 UTC


README

banner

这是一个针对伟大的 ramsey/uuid 包的简单封装。

安装

使用 Composer 需要此包

compose require eve/uuid

用法

为了简单和内部使用,eve 的 Uuid 类仅处理 Ramsey\Uuid v4 字符串。任何更高级的使用都需要直接使用 Ramsey\Uuid

use Eve\Uuid\Uuid;

// Generate a UUID string
$uuid = Uuid::generate();

// The package also comes with a handy global function
$uuid = uuid();

// Freeze the next generated value, useful for testing
$frozenValue = Uuid::freeze();
assert(Uuid::generate() === $frozenValue); // true

// You can also supply a custom value for freezing
Uuid::freeze('dummy');
assert(Uuid::generate() === 'dummy'); // true

// "Reset" UUID generation to normal. This can for example be put in PHPUnit's `tearDown` method. 
Uuid::unfreeze(); 

许可

当然是 MIT 许可。