-
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
Static create method #47
Comments
👍 |
In php 5.4+ you really don't need an extra line, you can wrap instantiators in parenthesis to chain method calls. echo (new Length(6.16, 'ft'))->toUnit('m'); |
This is true, but a static method feels more appropriate and the legibility of the code is better imho |
Sorry for not addressing this ticket earlier. It's a style judgement, and therefore somewhat arbitrary, but I'd prefer to lean toward existing language semantics rather than code around them. @fyrye's suggestion above is what I'd consider to be the recommended procedure for a one-liner unit conversion. |
I would like to give an example of when the static method could be useful: in some cases you have to instantiate a lot of |
Hmm, ok it looks like there are legit use cases here, and the added complexity is minimal. I'm ok with implementing this change. |
Thanks for the solid library.
What do you think about a static create method in the AbstractPhysicalQuantity class? Allowing: -
It's obviously nothing major, I've just got a few cases where I begrudge having an extra line just to declare the Length object when all I want is a simple conversion.
The text was updated successfully, but these errors were encountered: