Skip to content

Conversation

@emedchill
Copy link

This PR adds digits to the Number::currency() call to allow for better rounding.

* @return string|false
*/
public static function currency(int|float $number, string $in = 'USD', ?string $locale = null)
public static function currency(int|float $number, string $in = 'USD', ?string $locale = null, int $digits = null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://en.wikipedia.org/wiki/Fraction

Feel like $fractions would be better than $digits

Copy link
Author

@emedchill emedchill Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP has both fraction and digits in their naming convention (NumberFormatter::FRACTION_DIGITS) but I felt that simple number of $digits after the decimal was fine.

I can change it however we want though.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe follow the other functions and use $precision?

@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If possible, please consider releasing your code as a package so that the community can still take advantage of your contributions!

If you feel absolutely certain that this code corrects a bug in the framework, please "@" mention me in a follow-up comment with further explanation so that GitHub will send me a notification of your response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants