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 |
||
14 | class PrestasiServiceProvider extends ServiceProvider |
||
15 | { |
||
16 | /** |
||
17 | * Indicates if loading of the provider is deferred. |
||
18 | * |
||
19 | * @var bool |
||
20 | */ |
||
21 | protected $defer = false; |
||
22 | |||
23 | /** |
||
24 | * Bootstrap the application events. |
||
25 | * |
||
26 | * @return void |
||
27 | */ |
||
28 | public function boot() |
||
40 | |||
41 | /** |
||
42 | * Register the service provider. |
||
43 | * |
||
44 | * @return void |
||
45 | */ |
||
46 | public function register() |
||
58 | |||
59 | /** |
||
60 | * Get the services provided by the provider. |
||
61 | * |
||
62 | * @return array |
||
63 | */ |
||
64 | public function provides() |
||
71 | |||
72 | /** |
||
73 | * Loading and publishing package's config |
||
74 | * |
||
75 | * @return void |
||
76 | */ |
||
77 | protected function configHandle($publish = '') |
||
92 | |||
93 | /** |
||
94 | * Loading package routes |
||
95 | * |
||
96 | * @return void |
||
97 | */ |
||
98 | protected function routeHandle() |
||
102 | |||
103 | /** |
||
104 | * Loading and publishing package's translations |
||
105 | * |
||
106 | * @return void |
||
107 | */ |
||
108 | View Code Duplication | protected function langHandle($publish = '') |
|
118 | |||
119 | /** |
||
120 | * Loading and publishing package's views |
||
121 | * |
||
122 | * @return void |
||
123 | */ |
||
124 | View Code Duplication | protected function viewHandle($publish = '') |
|
134 | |||
135 | /** |
||
136 | * Publishing package's assets (JavaScript, CSS, images...) |
||
137 | * |
||
138 | * @return void |
||
139 | */ |
||
140 | protected function assetHandle($publish = '') |
||
148 | |||
149 | /** |
||
150 | * Publishing package's migrations |
||
151 | * |
||
152 | * @return void |
||
153 | */ |
||
154 | protected function migrationHandle($publish = '') |
||
164 | |||
165 | /** |
||
166 | * Publishing package's publics (JavaScript, CSS, images...) |
||
167 | * |
||
168 | * @return void |
||
169 | */ |
||
170 | public function publicHandle($publish = '') |
||
178 | |||
179 | /** |
||
180 | * Publishing package's seeds |
||
181 | * |
||
182 | * @return void |
||
183 | */ |
||
184 | public function seedHandle($publish = '') |
||
192 | |||
193 | /** |
||
194 | * Publishing package's all files |
||
195 | * |
||
196 | * @return void |
||
197 | */ |
||
198 | public function publishHandle() |
||
211 | } |
||
212 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.