Skip to content

Commit

Permalink
Fixes tests and StyleCI formatting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
elegasoft committed Mar 1, 2024
1 parent 488b0df commit 43067f0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Illuminate/Support/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,18 +241,18 @@ public static function clamp(int|float $number, int|float $min, int|float $max)
* @param string|null $locale
* @return string|false
*/
public function trim(int|float $number, int $precision = 2, ?int $maxPrecision = null, ?string $locale = null)
public static function trim(int|float $number, int $precision = 2, ?int $maxPrecision = null, ?string $locale = null)
{
$formatter = new NumberFormatter($locale, NumberFormatter::PATTERN_DECIMAL);
$formatter->setAttribute(NumberFormatter::ROUNDING_MODE, NumberFormatter::ROUND_DOWN);

$parts = explode('.', (string) $number);
$currentPrecision = strlen($parts[1]);

if (!is_null($maxPrecision)) {
if ( !is_null($maxPrecision)) {
$formatter->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS,
min($currentPrecision, $maxPrecision));
} elseif (!is_null($precision)) {
} elseif ( !is_null($precision)) {
$formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, min($currentPrecision, $precision));
}

Expand Down

0 comments on commit 43067f0

Please sign in to comment.