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 |
||
7 | class BtcE extends ExchangeAbstract |
||
8 | { |
||
9 | private $nonce = false; |
||
10 | |||
11 | |||
12 | /** |
||
13 | * @param $uri |
||
14 | * @param array $params |
||
15 | * @return mixed |
||
16 | * @throws \Exception |
||
17 | */ |
||
18 | 7 | public function send($uri, array $params = []) |
|
71 | |||
72 | /** |
||
73 | * |
||
74 | */ |
||
75 | 9 | public function setClient() |
|
79 | |||
80 | /** |
||
81 | * @param $btc |
||
82 | * @param $price |
||
83 | * @return mixed |
||
84 | * @throws \Exception |
||
85 | */ |
||
86 | 1 | View Code Duplication | public function buyOrder($btc, $price) |
95 | |||
96 | /** |
||
97 | * @param $btc |
||
98 | * @param $price |
||
99 | * @return mixed |
||
100 | */ |
||
101 | 1 | View Code Duplication | public function sellOrder($btc, $price) |
110 | |||
111 | /** |
||
112 | * @return mixed |
||
113 | * @throws \Exception |
||
114 | */ |
||
115 | 1 | public function getInfo() |
|
119 | |||
120 | /** |
||
121 | * @return mixed |
||
122 | */ |
||
123 | 1 | public function getTicker() |
|
127 | |||
128 | |||
129 | |||
130 | 1 | public function getOrders() |
|
136 | |||
137 | |||
138 | 1 | public function getTransactionHistory() |
|
142 | |||
143 | 1 | public function getTradeHistory() |
|
147 | |||
148 | |||
149 | |||
150 | 1 | public function cancelOrder($order_id) |
|
156 | |||
157 | |||
158 | } |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.