Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Use a math library other than moontoast/math #109
A math library is not required for this library unless users want to operate on the UUID as a 128-bit integer. For this purpose, the library has suggested moontoast/math as an optional dependency, and internally, this is what ramsey/uuid uses, if it is present. However, moontoast/math is no longer maintained.
I will either create a ramsey/math library that allows the use of different adapters for working with large numbers, or I want to find an existing math library that provides similar functionality.
I'm still giving this a lot of thought. Ideally, ramsey/uuid wouldn't need to know about any external number library at all. I would love to return an unsigned 128-bit integer (or at least 2 unsigned 64-bit integers) and let the caller handle the number by passing it to their preferred library.
To do this, I would need to return the number in string format, since PHP can't handle unsigned 64-bit integers, much less unsigned 128-bit integers. I can do this using bcmath or gmp, but that requires a system dependency, and not everyone has those installed. Likewise, I could use moontoast/math to create this string and return it (as just a string), but again, moontoast/math depends on bcmath.
If there were a pure PHP polyfill for bcmath or gmp, then I could use that to perform the calculations and return a string number. Then, the caller can use whatever math library they wish. This is my preferred approach, but I have yet to find a pure PHP polyfill for bcmath or gmp. phpseclib does provide a pure PHP implementation, but it is far more than I need, and I prefer that the polyfill provide the bcmath or gmp functions rather than an abstraction around them.