Total Complexity | 9 |
Total Lines | 85 |
Duplicated Lines | 28.24 % |
Coverage | 100% |
Changes | 0 |
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 |
||
12 | class TradeVolumeResponse implements ResponseInterface |
||
13 | { |
||
14 | /** |
||
15 | * @var string |
||
16 | */ |
||
17 | private $currency; |
||
18 | /** |
||
19 | * @var float |
||
20 | */ |
||
21 | private $volume; |
||
22 | /** |
||
23 | * @var FeeModel[] |
||
24 | */ |
||
25 | private $fees = []; |
||
26 | /** |
||
27 | * @var FeeModel[] |
||
28 | */ |
||
29 | private $feesMaker = []; |
||
30 | |||
31 | /** |
||
32 | * @param array $result |
||
33 | */ |
||
34 | 1 | public function manualMapping($result) |
|
35 | { |
||
36 | 1 | $this->currency = $result["currency"]; |
|
37 | 1 | $this->volume = $result["volume"]; |
|
38 | |||
39 | |||
40 | 1 | View Code Duplication | if (isset($result["fees"])) { |
|
|||
41 | 1 | foreach ($result["fees"] as $fee) { |
|
42 | 1 | $this->fees[] = new FeeModel( |
|
43 | 1 | $fee["fee"], |
|
44 | 1 | $fee["minfee"], |
|
45 | 1 | $fee["maxfee"], |
|
46 | 1 | $fee["nextfee"], |
|
47 | 1 | $fee["nextvolume"], |
|
48 | 1 | $fee["tiervolume"] |
|
49 | 1 | ); |
|
50 | 1 | } |
|
51 | 1 | } |
|
52 | |||
53 | 1 | View Code Duplication | if (isset($result["fees_maker"])) { |
54 | 1 | foreach ($result["fees_maker"] as $fee) { |
|
55 | 1 | $this->feesMaker[] = new FeeModel( |
|
56 | 1 | $fee["fee"], |
|
57 | 1 | $fee["minfee"], |
|
58 | 1 | $fee["maxfee"], |
|
59 | 1 | $fee["nextfee"], |
|
60 | 1 | $fee["nextvolume"], |
|
61 | 1 | $fee["tiervolume"] |
|
62 | 1 | ); |
|
63 | 1 | } |
|
64 | 1 | } |
|
65 | 1 | } |
|
66 | |||
67 | /** |
||
68 | * @return string |
||
69 | */ |
||
70 | 1 | public function getCurrency() |
|
71 | { |
||
72 | 1 | return $this->currency; |
|
73 | } |
||
74 | |||
75 | /** |
||
76 | * @return float |
||
77 | */ |
||
78 | 1 | public function getVolume() |
|
81 | } |
||
82 | |||
83 | /** |
||
84 | * @return FeeModel[] |
||
85 | */ |
||
86 | 1 | public function getFees() |
|
87 | { |
||
88 | 1 | return $this->fees; |
|
89 | } |
||
90 | |||
91 | /** |
||
92 | * @return FeeModel[] |
||
93 | */ |
||
94 | 1 | public function getFeesMaker() |
|
97 | } |
||
98 | |||
99 | |||
100 | } |
||
101 |
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.