mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-18 18:44:16 +00:00
Accept null values.
This commit is contained in:
@@ -99,12 +99,15 @@ class Steam
|
|||||||
/**
|
/**
|
||||||
* https://stackoverflow.com/questions/1642614/how-to-ceil-floor-and-round-bcmath-numbers
|
* https://stackoverflow.com/questions/1642614/how-to-ceil-floor-and-round-bcmath-numbers
|
||||||
*
|
*
|
||||||
* @param string $number
|
* @param null|string $number
|
||||||
* @param int $precision
|
* @param int $precision
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function bcround(string $number, int $precision = 0): string
|
public function bcround(?string $number, int $precision = 0): string
|
||||||
{
|
{
|
||||||
|
if(null === $number) {
|
||||||
|
return '0';
|
||||||
|
}
|
||||||
if (str_contains($number, '.')) {
|
if (str_contains($number, '.')) {
|
||||||
if ($number[0] !== '-') {
|
if ($number[0] !== '-') {
|
||||||
return bcadd($number, '0.'.str_repeat('0', $precision).'5', $precision);
|
return bcadd($number, '0.'.str_repeat('0', $precision).'5', $precision);
|
||||||
|
Reference in New Issue
Block a user