Fix Decimal rule for float values > 10

This commit is contained in:
toxxxa 2022-06-29 23:00:44 +03:00
parent 3dcd859d98
commit c7a6f2ebec
2 changed files with 5 additions and 1 deletions

View file

@ -70,6 +70,6 @@ final class Decimal extends AbstractRule
return $formatted;
}
return preg_replace('/^(\d.\d)0*/', '$1', $formatted);
return preg_replace('/^(\d+\.\d)0*$/', '$1', $formatted);
}
}

View file

@ -48,6 +48,10 @@ final class DecimalTest extends RuleTestCase
[new Decimal(1), 1.1],
[new Decimal(1), '1.3'],
[new Decimal(1), 1.50],
[new Decimal(1), 10.0],
[new Decimal(2), 10.00],
[new Decimal(1), 10.50],
[new Decimal(2), 10.50],
[new Decimal(3), '1.000'],
[new Decimal(3), 123456789.001],
];