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

InterestAmountCalculator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 25
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getInterestAmount() 0 5 1
A getPeriodInterestRate() 0 5 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