Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/helpers.php
  • Loading branch information
allanmcarvalho committed Nov 18, 2023
2 parents a064b4a + 4505a9b commit a23f7aa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static function from(Numerable|int|float|string|null $number): ?Numerable
if (is_numeric($number)) {
return new Numerable($number);
}

return null;
}

Expand All @@ -68,6 +69,7 @@ public static function parse(string $number, string $locale = null): ?Numerable
$formatter = new NumberFormatter($locale ?? config('app.locale', 'en'), NumberFormatter::DECIMAL);
$newNumber = preg_replace('/[^0-9,.]+/', '', $number);
$multiplier = in_array(ord(mb_substr($number, 0, 1)), [226, 45]) ? -1 : 1;

return $newNumber === '' ? null : new Numerable($formatter->parse($newNumber) * $multiplier);
}

Expand Down
1 change: 0 additions & 1 deletion tests/HelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
it('have num function', function () {
expect(function_exists('num'))->toBeTrue();
});

0 comments on commit a23f7aa

Please sign in to comment.