Skip to content

Commit

Permalink
add bitcoin parser fix, fixes moneyphp#542 and moneyphp#541 (moneyphp…
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikbosch authored Jan 9, 2019
1 parent 16288a1 commit 0ef4768
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Parser/BitcoinMoneyParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function parse($money, $forceCurrency = null)
$decimalSeparator = strpos($decimal, '.');

if (false !== $decimalSeparator) {
$decimal = rtrim($decimal, '0');
$lengthDecimal = strlen($decimal);
$decimal = str_replace('.', '', $decimal);
$decimal .= str_pad('', ($lengthDecimal - $decimalSeparator - $this->fractionDigits - 1) * -1, '0');
Expand Down
1 change: 1 addition & 0 deletions tests/Parser/BitcoinMoneyParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function bitcoinExamples()
["\xC9\x83.99", 99],
["\xC9\x8399.", 9900],
["\xC9\x830", '0'],
["\xC9\x830.020000000", 2],
];
}
}

0 comments on commit 0ef4768

Please sign in to comment.