Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
[Uid] add autowirable UidFactory #36097
This PR introduces the
$factory = new UidFactory(); $ulid = $factory->ulid(); $v1 = $factory->uuidV1(); $v3 = $factory->uuidV3($v1, 'foo'); $v4 = $factory->uuidV4(); $v5 = $factory->uuidV5($v1, 'foo')); $v6 = $factory->uuidV6();
This replaces the current static factories and empty constructors.
Having (at least) three different ways to do the same thing seems excessive:
$v1 = (new UidFactory())->createUuidV1(); $v1 = Uuid::v1(); $v1 = new UuidV1();
This component was introduced as a lightweight alternative to the full-featured Ramsey library, so we may reconsider all this and simplify things if possible. Thanks!
What I didn't mention in the description is that
We could remove the static factories and the nullable constructors. That would ensure ppl always use the configurable way to create UIDs. On the other hand, this requires more code (autowiring will help a lot of course).
see just above :)
i was hoping default sources fit 9/10 cases yes :) though ive no real experience with it, meaning i never had to alter such sources in practice.
For simplicity i tend to lean to (considering the UUID v4 case):
considering ramsey/uuid also has a static
That's 2 constructors :)