Total Complexity | 5 |
Total Lines | 59 |
Duplicated Lines | 100 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 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 | View Code Duplication | class OpenPositionsRequest implements RequestInterface |
|
|
|||
13 | { |
||
14 | |||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | private $txid; |
||
19 | /** |
||
20 | * @var bool |
||
21 | */ |
||
22 | private $docalcs = false; |
||
23 | |||
24 | /** |
||
25 | * OpenPositionsRequest constructor. |
||
26 | * @param string $txid |
||
27 | * @param bool $docalcs |
||
28 | */ |
||
29 | 2 | public function __construct($txid, $docalcs) |
|
30 | { |
||
31 | 2 | $this->txid = $txid; |
|
32 | 2 | $this->docalcs = $docalcs; |
|
33 | 2 | } |
|
34 | |||
35 | |||
36 | /** |
||
37 | * Returns the api request name |
||
38 | * |
||
39 | * @return string |
||
40 | */ |
||
41 | 1 | public function getMethod() |
|
42 | { |
||
43 | 1 | return 'OpenPositions'; |
|
44 | } |
||
45 | |||
46 | /** |
||
47 | * @return string |
||
48 | */ |
||
49 | 1 | public function getVisibility() |
|
50 | { |
||
51 | 1 | return VisibilityEnum::VISIBILITY_PRIVATE; |
|
52 | } |
||
53 | |||
54 | /** |
||
55 | * @return array |
||
56 | */ |
||
57 | 1 | public function getRequestData() |
|
58 | { |
||
59 | 1 | $ret = []; |
|
60 | 1 | $ret["txid"] = $this->txid; |
|
61 | 1 | $ret["docalcs"] = $this->docalcs; |
|
62 | 1 | return $ret; |
|
63 | } |
||
64 | |||
65 | /** |
||
66 | * @return string |
||
67 | */ |
||
68 | 1 | public function getResponseClassName() |
|
71 | } |
||
72 | } |
||
73 |
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.