-
Notifications
You must be signed in to change notification settings - Fork 77
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
List or verify if a unit exist in a given implementation #62
Comments
Hello, and thanks for your effort. Your option 1 seems like the easiest choice, but I don't know that it's as useful to an end user given that it takes a Option 2 runs into trouble in that the wrapper would end up having to instantiate a Option 3 seems like the best bet, though rather than directly accessing the Maybe something like:
(I didn't test that, so if you do submit a PR please provide a unit test to be sure it works). Having not looked at this code in a while, these static methods feel kinda messy to me. I remember the justification for implementing them (allow sharing newly-registered units between all objects of a given physical quantity), but it does fell cumbersome. Oh well. Thanks again. |
@triplepoint thank you for replying. Just a couple of questions:
Thank you |
…ound for PhpUnitsOfMeasure#63 (necessary for PhpUnitsOfMeasure#62 unit tests)
Hi @triplepoint... I had a bit of free time to finish... so if your reply to my previous questions are "yes", "yes", "yes" you can accept the pull request #62. |
Hi @triplepoint... any news about this, #63 and the pull request? |
Doing a review now of #64, looks pretty good so far (minor formatting comment aside). That glitch you reported in #63 is interesting. I'm going to spend a few minutes reproducing it on my local machine and see if there's an obvious fix. I don't really have a problem landing #64 as is, but it'd be nice to clear up #63 first if there's a quick fix. |
Closing, having merged #64 |
Hi all,
I'm thinking to create a method to verify if a given unit is available for a specific implementation (or at least to list all available units for that).
In my mind it can be very useful in:
I saw the
AbstractPhysicalQuantity::unitNameOrAliasesAlreadyRegistered()
, but it is protected, so inaccesible from the external classes.I have several options:
PhysicalQuantityInterface::unitAlreadyExists($unitInString)
; its implementation can "wrap" (adding just a couple of line of code) theunitNameOrAliasesAlreadyRegistered()
PhysicalQuantityInterface::unitAlreadyExists($unitStr)
; its implementation can directly access and loop over thethe static::$unitDefinitions
arrayPhysicalQuantityInterface::listExistingUnits()
; its implementation can returns an array of strings with all the existing units for that implementationI know users can access to
::getUnitDefinitions()
and loop over theUnitOfMeasure
objects, but it requires more effort for a developer.If you think this feature(s) can be useful I can quickly code it... just tell me what solution do you think is more suitable for the library (one between 1/2/3 or/and 4)...
The text was updated successfully, but these errors were encountered: