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 ProgramKeahlianServiceProvider 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 = '') | ||
| 88 | |||
| 89 | /** | ||
| 90 | * Loading package routes | ||
| 91 | * | ||
| 92 | * @return void | ||
| 93 | */ | ||
| 94 | protected function routeHandle() | ||
| 98 | |||
| 99 | /** | ||
| 100 | * Loading and publishing package's translations | ||
| 101 | * | ||
| 102 | * @return void | ||
| 103 | */ | ||
| 104 | View Code Duplication | protected function langHandle($publish = '') | |
| 114 | |||
| 115 | /** | ||
| 116 | * Loading and publishing package's views | ||
| 117 | * | ||
| 118 | * @return void | ||
| 119 | */ | ||
| 120 | View Code Duplication | protected function viewHandle($publish = '') | |
| 130 | |||
| 131 | /** | ||
| 132 | * Publishing package's assets (JavaScript, CSS, images...) | ||
| 133 | * | ||
| 134 | * @return void | ||
| 135 | */ | ||
| 136 | protected function assetHandle($publish = '') | ||
| 144 | |||
| 145 | /** | ||
| 146 | * Publishing package's migrations | ||
| 147 | * | ||
| 148 | * @return void | ||
| 149 | */ | ||
| 150 | protected function migrationHandle($publish = '') | ||
| 160 | |||
| 161 | /** | ||
| 162 | * Publishing package's publics (JavaScript, CSS, images...) | ||
| 163 | * | ||
| 164 | * @return void | ||
| 165 | */ | ||
| 166 | public function publicHandle($publish = '') | ||
| 174 | |||
| 175 | /** | ||
| 176 | * Publishing package's seeds | ||
| 177 | * | ||
| 178 | * @return void | ||
| 179 | */ | ||
| 180 | public function seedHandle($publish = '') | ||
| 188 | |||
| 189 | /** | ||
| 190 | * Publishing package's all files | ||
| 191 | * | ||
| 192 | * @return void | ||
| 193 | */ | ||
| 194 | public function publishHandle() | ||
| 207 | } | ||
| 208 | 
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.