Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
</include>
</coverage>
<testsuites>
<testsuite name="unit">
<directory>tests</directory>
<exclude>tests/Read</exclude>
<exclude>tests/Write</exclude>
</testsuite>
<testsuite name="write">
<directory>tests/Write</directory>
</testsuite>
Expand Down
2 changes: 1 addition & 1 deletion src/NumberFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static function format(
string $decimalSeparator = ".",
string $thousandsSeparator = ""
) {
if ($decimals == null) {
if ($decimals === null) {
// Get the current decimal point character according to the locale
// This is needed because (string)$number uses the locale's decimal separator
$locale = localeconv();
Expand Down
7 changes: 7 additions & 0 deletions tests/NumberFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ public function formattedNumbersProvider(): array
[1.236789, '1.24', 2],
[1, '1.00', 2],
[1.000, '1', null],

// An explicit 0 must round to a whole number, not fall back
// to auto-detecting the decimals present in the input
[12.345, '12', 0],
[0.5, '1', 0],
[1.0, '1', 0],
[0.0, '0', 0],
];
}
}
Loading