decodelabs / guidance
Generalised UUID generation and parsing interface
v0.1.12
2024-08-22 02:41 UTC
Requires
- php: ^8.1
- brick/math: ^0.10|^0.11|^0.12
- decodelabs/exceptional: ^0.4.4
- decodelabs/veneer: ^0.11.6
- ramsey/uuid: ^4.7
Requires (Dev)
- decodelabs/phpstan-decodelabs: ^0.6.7
README
Generalised UUID generation and parsing interface
Guidance provides a simplified interface for generating and parsing UUIDs of various types. It is designed to be used as a common interface for other libraries that need to work with UUIDs, without having to worry about the specifics of each type and implementation of the generator.
Guidance provides a stripped down front end over the Ramsey UUID library by default, but can be extended to support other implementations where required.
Get news and updates on the DecodeLabs blog.
Installation
Install via Composer:
composer require decodelabs/guidance
Usage
use DecodeLabs\Guidance; use DecodeLabs\Guidance\Format; // Generate a v4 UUID $v4 = Guidance::createV4(); $version = $v4->getVersion(); // Version::V4 $string1 = (string)$v4; // Full UUID string $string2 = $v4->shorten(); // Base 62 (default) encoded UUID $string3 = $v4->shorten(Format::FlickrBase58); // Base 58 encoded UUID $new1 = Guidance::from($string1); // Parse full UUID string $new2 = Guidance::fromShortString($string3, Format::FlickrBase58);
Licensing
Guidance is licensed under the MIT License. See LICENSE for the full license text.