Skip to content

Commit

Permalink
stan 9
Browse files Browse the repository at this point in the history
  • Loading branch information
nikuscs committed Jul 8, 2024
1 parent 10fd5c4 commit 6a1264c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 1 addition & 2 deletions config/helpers.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


return [
/*
|--------------------------------------------------------------------------
Expand All @@ -14,5 +13,5 @@
'scale' => 10,
'storage_scale' => 10,
'rounding_mode' => \Brick\Math\RoundingMode::DOWN,
]
],
];
13 changes: 8 additions & 5 deletions src/Helpers/Math/Math.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,18 @@ public static function of(

return new Math(
$number,
$scale ?? config('helpers.math.scale', 10),
$storageScale ?? config('helpers.math.scale', 10),
// @phpstan-ignore-next-line
$scale ?? (int) config('helpers.math.scale', 10),
// @phpstan-ignore-next-line
$storageScale ?? (int) config('helpers.math.scale', 10),
// @phpstan-ignore-next-line
$roundingMode ?? config('helpers.math.rounding_mode', RoundingMode::DOWN)
);
}

/**
*
* @param int|float|string|BigDecimal ...$numbers
* @return Math
*
* @throws DivisionByZeroException
* @throws MathException
* @throws NumberFormatException
Expand Down Expand Up @@ -573,9 +575,10 @@ public function fromStorage(): Math
*/
public function toNumber(): BigDecimal
{
if($this->number instanceof BigDecimal){
if ($this->number instanceof BigDecimal) {
return $this->number;
}

return BigDecimal::of($this->number);
}

Expand Down

0 comments on commit 6a1264c

Please sign in to comment.