eve/uuid

eve's simple Ramsey UUID wrapper

Maintainers

Details

github.com/Eveio/uuid

Source

Installs: 15 003

Dependents: 1

Suggesters: 0

Security: 0

Stars: 6

Watchers: 3

Forks: 0

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

This package is auto-updated.

Last update: 2024-10-26 21:14:12 UTC


README

banner

A simple wrapper for the great ramsey/uuid package.

Installation

Require the package with Composer:

compose require eve/uuid

Usage

For the sake of simplicity and internal usage, eve's Uuid class only deals with Ramsey\Uuid v4 as strings. Any more advanced usage will have to be done directly with 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(); 

License

MIT, of course.