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 |
||
10 | class AddLotMiddleware |
||
11 | { |
||
12 | /** |
||
13 | * @var Guard |
||
14 | */ |
||
15 | protected $auth; |
||
16 | |||
17 | /** |
||
18 | * @var LotRepository |
||
19 | */ |
||
20 | protected $lots; |
||
21 | |||
22 | /** |
||
23 | * AddLotMiddleware constructor. |
||
24 | * @param Guard $auth |
||
25 | * @param LotRepository $lotRepository |
||
26 | */ |
||
27 | public function __construct(Guard $auth, LotRepository $lotRepository) |
||
32 | |||
33 | /** |
||
34 | * Handle an incoming request. |
||
35 | * |
||
36 | * @param \Illuminate\Http\Request $request |
||
37 | * @param \Closure $next |
||
38 | * @param string|null $guard |
||
39 | * @return mixed |
||
40 | */ |
||
41 | public function handle($request, Closure $next, $guard = null) |
||
62 | |||
63 | private function issetAmount($lot, $requestComision) |
||
72 | |||
73 | private function blockAmount($lot, $tax) |
||
79 | |||
80 | View Code Duplication | public function blockSumm($tax, $amount) |
|
97 | |||
98 | |||
99 | /** |
||
100 | * @param $lot |
||
101 | * @param $tax |
||
102 | * @return bool |
||
103 | */ |
||
104 | private function eraseFromWallet($lot, $tax) |
||
119 | /** |
||
120 | * @param $tax |
||
121 | * @param $amount |
||
122 | * @return bool |
||
123 | */ |
||
124 | View Code Duplication | public function eraseSummFromWallet($tax, $amount) |
|
140 | |||
141 | /** |
||
142 | * @param $tax |
||
143 | * @param $amount |
||
144 | * @return float|int |
||
145 | */ |
||
146 | public function calcEraseSumm($tax, $amount) |
||
150 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.