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 namespace Propaganistas\LaravelIntl; |
||
7 | class IntlServiceProvider extends ServiceProvider |
||
8 | { |
||
9 | /** |
||
10 | * Register the service provider. |
||
11 | * |
||
12 | * @return void |
||
13 | */ |
||
14 | 144 | public function register() |
|
22 | |||
23 | /** |
||
24 | * Bootstrap the application services. |
||
25 | * |
||
26 | * @return void |
||
27 | */ |
||
28 | 144 | public function boot() |
|
36 | |||
37 | /** |
||
38 | * Register the country repository. |
||
39 | * |
||
40 | * @return void |
||
41 | */ |
||
42 | 144 | View Code Duplication | protected function registerCountry() |
52 | |||
53 | /** |
||
54 | * Register the currency repository. |
||
55 | * |
||
56 | * @return void |
||
57 | */ |
||
58 | 144 | View Code Duplication | protected function registerCurrency() |
68 | |||
69 | /** |
||
70 | * Register the language repository. |
||
71 | * |
||
72 | * @return void |
||
73 | */ |
||
74 | 144 | View Code Duplication | protected function registerLanguage() |
84 | |||
85 | /** |
||
86 | * Register the number repository. |
||
87 | * |
||
88 | * @return void |
||
89 | */ |
||
90 | 144 | View Code Duplication | protected function registerNumber() |
100 | |||
101 | /** |
||
102 | * Register the date handler. |
||
103 | * |
||
104 | * @return void |
||
105 | */ |
||
106 | 144 | protected function registerDate() |
|
110 | |||
111 | /** |
||
112 | * Set locales on sub-libraries. |
||
113 | * |
||
114 | * @throws \Punic\Exception\InvalidLocale |
||
115 | */ |
||
116 | 144 | protected function setLocale() |
|
124 | } |
||
125 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.