-
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
How to get original unit? #77
Comments
That's a good question; there's currently no way to get just the original unit back out. I think the best you can get is to cast a PhysicalQuantity object to a string, and then break on the space, like so (untested): $height = new Length(6.16, 'feet');
list($original_value, $original_unit) = explode(' ', (string) $height);
echo $original_unit; // This is what you're looking for Please note that this strategy will return the canonical name of the original unit, not the particular alias you might've actually passed into the constructor. So for instance if you created a Mass object with But it does seem like there should be a more direct way to fetch the original value and the original unit. That's probably worth adding. Does that help? |
How about adding a getter method in the AbstractPhysicalQuantity class? |
Same is for originalValue -> currently there are no getters for this. Should we just make a PR? |
How can I get the original unit of an instance?
The text was updated successfully, but these errors were encountered: