Passed
Push — master ( 9ee920...841385 )
by Kauri
52s
created

InterestAmountCalculator::getPeriodInterestRate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Kauri\Loan;
6
7
8
class InterestAmountCalculator implements InterestAmountCalculatorInterface
9
{
10
    /**
11
     * Calculate interest amount for present value based on interest rate
12
     * @param float $presentValue
13
     * @param float $interestRate
14
     * @return float
15
     */
16 4
    public function getInterestAmount(float $presentValue, float $interestRate): float
17
    {
18 4
        $interestAmount = ($presentValue * ($interestRate / 100));
19 4
        return $interestAmount;
20
    }
21
22
    /**
23
     * @param float $interestRate Yearly interest rate (based on 360 days)
24
     * @param float $periodLength Period length in days
25
     * @return float
26
     */
27 4
    public function getPeriodInterestRate(float $interestRate, float $periodLength): float
28
    {
29 4
        $periodRate = $interestRate / 360 * $periodLength;
30 4
        return (float) $periodRate;
31
    }
32
}
33