-
Notifications
You must be signed in to change notification settings - Fork 4
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
Support for bitcoin #1
Comments
Right now decimal places are controlled by Money class constant called GAAP_PRECISION, which is equal to 4 (as per GAAP advice on money value storing for banks). Constant is used without late static binding, so it's not easy to override this behavior. If you need 8 decimal places, I can try to change all self references to use static keyword. You could then simply extend Money class and only redeclare const GAAP_PRECISION = 8; in it. I used self references, because I was strongly considering declaring classes as final, since these are Value Objects that should not be changed (also via inheritance). There's simply no other simple way to control decimal precision and I don't know if late static binding won't bring performance hit to the table, but we could try. |
BTC is already recognized as valid currency (since Ruby Money recognizes it), see https://github.com/keiosweb/moneyright/blob/master/src/config/currency_non_iso.json |
I have implemented a BigMoney class: https://github.com/josecelano/money from @mathiasverraes' Money class using Decimal class instead of integer to store amount. I have used this library: https://github.com/Litipk/php-bignumbers For the time being I do not need to extend Decimal class but I wanted to do it to add new shorcuts methods like greaterThan, ... See : Coder-Spirit/php-bignumbers#35 (comment) I suppose in that case inheritance is valid even for a Value Object. I want to add new behavior to the class but each VO instance is inmutable. |
Well, you basically reimplemented our Money class, since we use string representation of money with all operations performed via BCMath functions :) |
Tell me if you want that late static binding here or are you going to be ok with your BigMoney? |
I have to think about it. First. If I want to use one class or two (Money and BigMoney from @mathiasverraes) |
if 4 decimal places arithmetic is GAAP for 2 decimal place currency, would we not want 10 decimal places arithmetic for 8 decimal currency? |
+1 for BTC support btw |
I have a problem using @mathiasverraes Money library: https://github.com/mathiasverraes/money
becuase max integer in 32 bits systems is to small for bitcoin becuase it uses 8 decimal places. See
moneyphp/money#79
I suppose there is no problem with this library, or is there?
The text was updated successfully, but these errors were encountered: