Skip to content

Commit

Permalink
ADD string to number normalize
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-cervenak committed Jul 12, 2024
1 parent 9ab4860 commit 32aac38
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wamesk/utils",
"version": "1.3.0",
"version": "1.3.1",
"description": "PHP Utils and Helpers.",
"keywords": [
"utils",
Expand Down
18 changes: 8 additions & 10 deletions src/Helpers/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,17 @@ public static function calculate($number, $coefficient, $decimal, $round): float


/**
* @param float|int $number
* @param float|int|string $number
*
* @return int|float
* @return float
*/
public static function normalize(float|int $number): int|float
public static function normalize(float|int|string $number): float
{
$return = str_replace(',', '.', $number);
return $return;
//dd($number, $return);
return (float) str_replace(',', '.', $number);

return match (gettype($number)) {
'float' => (float) $return,
'integer' => (int) $return,
};
// return match (gettype($number)) {
// 'float' => (float) $return,
// 'integer' => (int) $return,
// };
}
}

0 comments on commit 32aac38

Please sign in to comment.