Closed TAGHREEDAA closed 1 month ago
I got an issue while trying to multiply by float multiplier less than 1 values
example: $price = (new Money(4320, new Currency('SAR')))->multiply(0.78)->multiply(2); this gives zero result because 0.78is not a string
$price = (new Money(4320, new Currency('SAR')))->multiply(0.78)->multiply(2);
0.78
I suggest to modify the multiply function here
public function multiply(float|string $multiplier, int $roundingMode = self::ROUND_HALF_UP): Money { if (is_int($multiplier) || is_float($multiplier)) { $multiplier = (string) $multiplier; } $product = $this->round(self::$calculator::multiply($this->amount, $multiplier), $roundingMode); return new self($product, $this->currency); }
No float :), it has been explained before
I got an issue while trying to multiply by float multiplier less than 1 values
example:
$price = (new Money(4320, new Currency('SAR')))->multiply(0.78)->multiply(2);
this gives zero result because0.78
is not a stringI suggest to modify the multiply function here