Skip to content
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

Add Float and Int formatters #32

Closed
wants to merge 8 commits into from
Closed

Add Float and Int formatters #32

wants to merge 8 commits into from

Conversation

514sid
Copy link

@514sid 514sid commented Sep 3, 2023

This PR adds Float and Int formatters based on my Num package, which support functionality for automatically detecting decimal separators in strings.

You can check the test file to see how it converts values based on the provided decimal separator:
https://github.com/514sid/num/blob/v1.x/tests/NumTest.php

@michael-rubel
Copy link
Owner

Hello @514sid! 👋

It feels that formatters are intended more for higher-level formatting than primitive operations like type conversion. Also, it seems I have similar functionality in this package. It automatically converts any convention you might pass to decimal.

Still, if you want to include this particular implementation in your project, you can register these by placing them in the Formatters folder.

Thank you for your pull request! ❤

@514sid
Copy link
Author

514sid commented Sep 3, 2023

Hi @michael-rubel,

The Num helper works a bit differently. It is more useful when you need to convert strings to integers or floats. It functions more as the opposite version of LocaleNumberFormatter.

However, thank you for your response, and feel free to merge it if you change your mind in the future.

@michael-rubel
Copy link
Owner

@514sid you can use asFloat() or asInteger() methods on the Number object though.

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.

2 participants