| @@ 44-50 (lines=7) @@ | ||
| 41 | return Money::fromCents((float) $result); |
|
| 42 | } |
|
| 43 | ||
| 44 | public function getPercentage(float $percentage): Money |
|
| 45 | { |
|
| 46 | $percentage = bcdiv((string) $percentage, '100', self::CALCULATION_SCALE); |
|
| 47 | $result = bcmul($this->amount, (string) $percentage, self::CALCULATION_SCALE); |
|
| 48 | ||
| 49 | return Money::fromCents((float) $result); |
|
| 50 | } |
|
| 51 | ||
| 52 | public function applyPercentage(float $percentage): Money |
|
| 53 | { |
|
| @@ 59-73 (lines=15) @@ | ||
| 56 | return $this->add($percentage); |
|
| 57 | } |
|
| 58 | ||
| 59 | public function getInterest(float $rate, int $duration): Money |
|
| 60 | { |
|
| 61 | $interest = bcdiv((string) $rate, '100', self::CALCULATION_SCALE); |
|
| 62 | $result = bcmul( |
|
| 63 | bcmul( |
|
| 64 | $this->amount, |
|
| 65 | (string) $duration, |
|
| 66 | self::CALCULATION_SCALE |
|
| 67 | ), |
|
| 68 | (string) $interest, |
|
| 69 | self::CALCULATION_SCALE |
|
| 70 | ); |
|
| 71 | ||
| 72 | return Money::fromCents((float) $result); |
|
| 73 | } |
|
| 74 | ||
| 75 | public function applyInterest(float $rate, int $duration): Money |
|
| 76 | { |
|