php-extended/php-uuid-object

php-uuid-interface 库的实现


README

php-uuid-interface 库的实现

coverage build status

安装

此库的安装通过 composer 完成,所有类的自动加载都通过它们的自动加载器完成。

  • 官方网站下载 composer.phar
  • 然后运行以下命令以将此库作为依赖项安装
  • php composer.phar require php-extended/php-uuid-object ^7

基本用法

此库可以使用以下方式使用


use PhpExtended\Uuid\Uuid;

$uuid = new Uuid(0x01234567, 0x89ab, 0xcdef, 0xfe, 0xdc, 0xba9876, 0x543210);

$uuid->__toString(); // 01234567-89ab-cdef-fedc-ba9876543210

解析 uuid


use PhpExtended\Uuid\UuidParser;

$parser = new UuidParser();
$uuid = $parser->parse('<put here your uuid string>');
// $uuid instanceof UuidInterface

按需创建 uuid,请执行


use PhpExtended\Uuid\UuidV4Factory();

$factory = new UuidV4Factory();
$uuid = $factory->create(); // 5F935265-8863-4672-FAB9-27097EF73660

许可证

MIT(见许可证文件)。