Conditions | 2 |
Paths | 2 |
Total Lines | 11 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
17 | 6 | public function getPaymentAmount(float $presentValue, float $ratePerPeriod, float $numberOfPeriods): float |
|
18 | { |
||
19 | 6 | if ($ratePerPeriod > 0) { |
|
20 | 3 | $payment = (($ratePerPeriod / 100) * $presentValue) / (1 - pow(1 + ($ratePerPeriod / 100), |
|
21 | 3 | -$numberOfPeriods)); |
|
22 | } else { |
||
23 | 3 | $payment = $presentValue / $numberOfPeriods; |
|
24 | } |
||
25 | |||
26 | 6 | return $payment; |
|
27 | } |
||
28 | } |
||
29 |