eig / uuid
UUID allowing easy generation and assignment for event sourced systems
Installs: 1 273
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 2
Open Issues: 0
Requires
- php: ^8.0.2
- ramsey/uuid: ^4.6.0
Requires (Dev)
- mockery/mockery: dev-master
- php-coveralls/php-coveralls: ^2.5.3
- phpunit/phpunit: ^9.5.10
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
$id
or 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;
}
}