Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate UUID using VERSION_* constant should be possible #42

Open
BenExile opened this issue Oct 19, 2017 · 1 comment
Open

Generate UUID using VERSION_* constant should be possible #42

BenExile opened this issue Oct 19, 2017 · 1 comment

Comments

@BenExile
Copy link

BenExile commented Oct 19, 2017

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?

@webpatser
Copy link
Owner

Yes. Good point. I will look into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants