Add NumberFormatter helper class for number formatting
- Introduced a new helper class `NumberFormatter` with a method `commaToDot` to convert numbers formatted with commas to a dot notation. - The method also trims whitespace and removes percentage signs for cleaner data handling. This commit enhances the application's ability to process numerical data consistently, supporting future financial data operations.
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Helpers;
|
||||||
|
|
||||||
|
class NumberFormatter
|
||||||
|
{
|
||||||
|
public static function commaToDot($text)
|
||||||
|
{
|
||||||
|
$text = trim($text);
|
||||||
|
$text = str_replace(".", "", $text);
|
||||||
|
$text = str_replace(",", ".", $text);
|
||||||
|
$text = str_replace("%", "", $text);
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user