-
Notifications
You must be signed in to change notification settings - Fork 11.7k
toEnglishFormat() / add number conversion helper #57669
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
Changes from all commits
723ffa6
4cbae17
0bdfdf2
0000a3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -439,4 +439,15 @@ protected static function ensureIntlExtensionIsInstalled() | |||||||
| throw new RuntimeException('The "intl" PHP extension is required to use the ['.$method.'] method.'); | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| /** | ||||||||
| * Converting Persian/Arabic digits to English | ||||||||
| * @param mixed $value | ||||||||
| * @return bool|float|int | ||||||||
| */ | ||||||||
| public static function toEnglishFormat($value) | ||||||||
| { | ||||||||
| $numberFormatter = new NumberFormatter('ar-u-nu-latn', NumberFormatter::DECIMAL); | ||||||||
| return $numberFormatter->parse($value); | ||||||||
|
Comment on lines
+450
to
+451
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could even use internal methods:
Suggested change
|
||||||||
| } | ||||||||
| } | ||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -523,3 +523,16 @@ | |||||
| return is_null($callback) ? $value : $callback($value); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| if (! function_exists('to_english_numbers')) { | ||||||
| /** | ||||||
| * Converting Persian/Arabic digits to English | ||||||
| * @param mixed $value | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this really
Suggested change
?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created this function to Number helper so we don't need to repeat it here. I'll remove that from helper.php |
||||||
| * @return string | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After using
Suggested change
|
||||||
| */ | ||||||
| function to_english_numbers($value): string | ||||||
|
Comment on lines
+529
to
+533
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How would I know that this is specific to Persian/Arabic digits from the helper name alone? And these are not English, the are Arabic numbers, just not Eastern Arabic numerals, but Western Arabic numerals. And what about other numbering systems? |
||||||
| { | ||||||
| return Number::toEnglishFormat($value); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
bool?