BondYTMCalculatorFactory   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 130
Duplicated Lines 79.23 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 1
dl 103
loc 130
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A newAnnualCouponsBond() 15 15 1
A newSemiAnnualCouponsBond() 16 16 1
A newQuarterlyCouponsBond() 16 16 1
A newMonthlyCouponsBond() 16 16 1
A newCustomCouponFrequencyBond() 0 17 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
6
    use FinanCalc\Calculators\BondYTMCalculator;
7
    use FinanCalc\Interfaces\Calculator\CalculatorFactoryAbstract;
8
9
    /**
10
     * Class BondYTMCalculatorFactory
11
     * @package FinanCalc\Calculators\Factories
12
     */
13 View Code Duplication
    class BondYTMCalculatorFactory 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\\BondYTMCalculator';
16
17
        /**
18
         * @param $bondFaceValue
19
         * @param $bondMarketValue
20
         * @param $bondAnnualCouponRate
21
         * @param $bondYearsToMaturity
22
         * @return BondYTMCalculator
23
         * @internal param $bondVIR
24
         */
25
        public function newAnnualCouponsBond(
26
            $bondFaceValue,
27
            $bondMarketValue,
28
            $bondAnnualCouponRate,
29
            $bondYearsToMaturity
30
        ) {
31
            return $this->manufactureInstance(
32
                [
33
                    $bondFaceValue,
34
                    $bondMarketValue,
35
                    $bondAnnualCouponRate,
36
                    $bondYearsToMaturity
37
                ]
38
            );
39
        }
40
41
        /**
42
         * @param $bondFaceValue
43
         * @param $bondMarketValue
44
         * @param $bondAnnualCouponRate
45
         * @param $bondYearsToMaturity
46
         * @return BondYTMCalculator
47
         * @internal param $bondVIR
48
         */
49
        public function newSemiAnnualCouponsBond(
50
            $bondFaceValue,
51
            $bondMarketValue,
52
            $bondAnnualCouponRate,
53
            $bondYearsToMaturity
54
        ) {
55
            return $this->manufactureInstance(
56
                [
57
                    $bondFaceValue,
58
                    $bondMarketValue,
59
                    $bondAnnualCouponRate,
60
                    $bondYearsToMaturity,
61
                    2
62
                ]
63
            );
64
        }
65
66
        /**
67
         * @param $bondFaceValue
68
         * @param $bondMarketValue
69
         * @param $bondAnnualCouponRate
70
         * @param $bondYearsToMaturity
71
         * @return BondYTMCalculator
72
         * @internal param $bondVIR
73
         */
74
        public function newQuarterlyCouponsBond(
75
            $bondFaceValue,
76
            $bondMarketValue,
77
            $bondAnnualCouponRate,
78
            $bondYearsToMaturity
79
        ) {
80
            return $this->manufactureInstance(
81
                [
82
                    $bondFaceValue,
83
                    $bondMarketValue,
84
                    $bondAnnualCouponRate,
85
                    $bondYearsToMaturity,
86
                    4
87
                ]
88
            );
89
        }
90
91
        /**
92
         * @param $bondFaceValue
93
         * @param $bondMarketValue
94
         * @param $bondAnnualCouponRate
95
         * @param $bondYearsToMaturity
96
         * @return BondYTMCalculator
97
         * @internal param $bondVIR
98
         */
99
        public function newMonthlyCouponsBond(
100
            $bondFaceValue,
101
            $bondMarketValue,
102
            $bondAnnualCouponRate,
103
            $bondYearsToMaturity
104
        ) {
105
            return $this->manufactureInstance(
106
                [
107
                    $bondFaceValue,
108
                    $bondMarketValue,
109
                    $bondAnnualCouponRate,
110
                    $bondYearsToMaturity,
111
                    12
112
                ]
113
            );
114
        }
115
116
        /**
117
         * @param $bondFaceValue
118
         * @param $bondMarketValue
119
         * @param $bondAnnualCouponRate
120
         * @param $bondYearsToMaturity
121
         * @param $bondPaymentFrequency
122
         * @return BondYTMCalculator
123
         * @internal param $bondVIR
124
         */
125
        public function newCustomCouponFrequencyBond(
126
            $bondFaceValue,
127
            $bondMarketValue,
128
            $bondAnnualCouponRate,
129
            $bondYearsToMaturity,
130
            $bondPaymentFrequency
131
        ) {
132
            return $this->manufactureInstance(
133
                [
134
                    $bondFaceValue,
135
                    $bondMarketValue,
136
                    $bondAnnualCouponRate,
137
                    $bondYearsToMaturity,
138
                    $bondPaymentFrequency
139
                ]
140
            );
141
        }
142
    }
143
}
144