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 NilaiServiceProvider 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='') |
||
90 | |||
91 | /** |
||
92 | * Loading package routes |
||
93 | * |
||
94 | * @return void |
||
95 | */ |
||
96 | protected function routeHandle() |
||
100 | |||
101 | /** |
||
102 | * Loading and publishing package's translations |
||
103 | * |
||
104 | * @return void |
||
105 | */ |
||
106 | View Code Duplication | protected function langHandle($publish='') |
|
116 | |||
117 | /** |
||
118 | * Loading and publishing package's views |
||
119 | * |
||
120 | * @return void |
||
121 | */ |
||
122 | View Code Duplication | protected function viewHandle($publish='') |
|
132 | |||
133 | /** |
||
134 | * Publishing package's assets (JavaScript, CSS, images...) |
||
135 | * |
||
136 | * @return void |
||
137 | */ |
||
138 | protected function assetHandle($publish='') |
||
146 | |||
147 | /** |
||
148 | * Publishing package's migrations |
||
149 | * |
||
150 | * @return void |
||
151 | */ |
||
152 | protected function migrationHandle($publish='') |
||
162 | |||
163 | public function publicHandle($publish='') |
||
171 | |||
172 | public function seedHandle($publish='') |
||
180 | |||
181 | public function publishHandle() |
||
192 | } |
||
193 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.