eig/uuid
最新稳定版本:2.5.2
Composer 安装命令:
composer require eig/uuid
包简介
UUID allowing easy generation and assignment for event sourced systems
关键字:
README 文档
README
Supported PHP Versions
- 7.2
- 7.3
- 7.4
- 8.0
Version Support
- For PHP 5.5 use the 0.0.5 branch releases
- For PHP 5.6 use the 1.1.x branch releases
- For PHP 7.1 use the 2.1.0 release
- For PHP 7.2 use the 2.4.x release
- For PHP 8.0+ use the 2.5.x release
Description
A wrapper package for easy use of the excellent Ramsey\UUID package. Currently the package generates a version 4 UUID according to RFC 4122.
This package provides 2 methods of generating a UUID.
- Static Facade UUID with a generate method.
- AssignUUID Trait that defaults to a class variable of
$idor accepts the string name of a class variable to assign the uuid to.
Static Method Example
use eig\UUID;
class Example {
protected $id;
public function __construct()
{
$this->id = UUID::generate();
}
}
AssignUUID Trait Example
use eig\UUID\AssignUUID;
class Example
{
use AssignUUID;
/**
* @var
*/
protected $id;
/**
* Example constructor.
*/
public function __construct ()
{
$this->assignUUID();
}
/**
* getID
* @return mixed
*/
public function getID()
{
return $this->id;
}
}
Or with a class variable other than $id
use eig\UUID\AssignUUID;
/**
* Class AlternateFieldExample
* @package eig\UUID
* @license MIT
* @author James Johnson
* @author Excellent InGenuity LLC
*/
class AlternateFieldExample
{
use AssignUUID;
/**
* @var
*/
protected $alternateID;
/**
* AlternateFieldExample constructor.
*/
public function __construct ()
{
$this->assignUUID('alternateID');
}
/**
* getAlternateID
* @return mixed
*/
public function getAlternateID()
{
return $this->alternateID;
}
}
统计信息
- 总下载量: 1.59k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-11-14