DebtAmortizatorFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 81
Duplicated Lines 92.59 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 1
cbo 2
dl 75
loc 81
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A newYearlyDebtAmortization() 11 11 1
A newMonthlyDebtAmortization() 11 11 1
A newDailyDebtAmortization() 11 11 1
A newDebtAmortizationCustomPeriodLength() 10 15 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace FinanCalc\Calculators\Factories {
4
5
    use FinanCalc\Calculators\DebtAmortizator;
6
    use FinanCalc\Interfaces\Calculator\CalculatorFactoryAbstract;
7
    use FinanCalc\Utils\Time\TimeSpan;
8
9
    /**
10
     * Class DebtAmortizatorFactory
11
     * @package FinanCalc\Calculators\Factories
12
     */
13 View Code Duplication
    class DebtAmortizatorFactory extends CalculatorFactoryAbstract
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
    {
15
        const MANUFACTURED_CLASS_NAME = 'FinanCalc\\Calculators\\DebtAmortizator';
16
17
        /**
18
         * @param $debtPrincipal
19
         * @param $debtNoOfPeriods
20
         * @param $debtInterest
21
         * @return DebtAmortizator
22
         */
23
        public function newYearlyDebtAmortization($debtPrincipal, $debtNoOfPeriods, $debtInterest)
24
        {
25
            return $this->manufactureInstance(
26
                [
27
                    $debtPrincipal,
28
                    $debtNoOfPeriods,
29
                    TimeSpan::asDuration(1),
30
                    $debtInterest
31
                ]
32
            );
33
        }
34
35
        /**
36
         * @param $debtPrincipal
37
         * @param $debtNoOfPeriods
38
         * @param $debtInterest
39
         * @return DebtAmortizator
40
         */
41
        public function newMonthlyDebtAmortization($debtPrincipal, $debtNoOfPeriods, $debtInterest)
42
        {
43
            return $this->manufactureInstance(
44
                [
45
                    $debtPrincipal,
46
                    $debtNoOfPeriods,
47
                    TimeSpan::asDuration(0, 1),
48
                    $debtInterest
49
                ]
50
            );
51
        }
52
53
        /**
54
         * @param $debtPrincipal
55
         * @param $debtNoOfPeriods
56
         * @param $debtInterest
57
         * @return DebtAmortizator
58
         */
59
        public function newDailyDebtAmortization($debtPrincipal, $debtNoOfPeriods, $debtInterest)
60
        {
61
            return $this->manufactureInstance(
62
                [
63
                    $debtPrincipal,
64
                    $debtNoOfPeriods,
65
                    TimeSpan::asDuration(0, 0, 1),
66
                    $debtInterest
67
                ]
68
            );
69
        }
70
71
        /**
72
         * @param $debtPrincipal
73
         * @param $debtNoOfPeriods
74
         * @param $debtInterest
75
         * @param TimeSpan $debtPeriodLength
76
         * @return \FinanCalc\Interfaces\Calculator\CalculatorAbstract
77
         */
78
        public function newDebtAmortizationCustomPeriodLength(
79
            $debtPrincipal,
80
            $debtNoOfPeriods,
81
            $debtInterest,
82
            TimeSpan $debtPeriodLength
83
        ) {
84
            return $this->manufactureInstance(
85
                [
86
                    $debtPrincipal,
87
                    $debtNoOfPeriods,
88
                    $debtPeriodLength,
89
                    $debtInterest
90
                ]
91
            );
92
        }
93
    }
94
}
95