webpatser/laravel-uuid

Generate UUID using VERSION_* constant should be possible

BenExile opened this issue · 1 comments

It seems counter-intuitive that it is not possible to generate a specific version of a UUID using the Uuid::VERSION_* constants e.g. Uuid::generate(Uuid::VERSION_4);. As this library currently supports PHP >= 7.0.0 the use of private visibility constants isn't possible without a major version bump.

One solution is making these constants private (possibly static) properties. This would remove them from the public scope and avoid any confusion around their use.

The other possible solution is to add them as cases in the switch statement that determines which type of UUID to generate:

switch ((int)$ver) {
    // [...]
    case 4:
    case self::VERSION_4:
        return new static(static::mintRand());
    // [...]

Thoughts?

Yes. Good point. I will look into this.