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 Distilleries\Messenger; |
||
| 9 | class MessengerServiceProvider extends ServiceProvider { |
||
| 10 | |||
| 11 | |||
| 12 | protected $package = 'messenger'; |
||
| 13 | protected $namespace = 'Distilleries\Messenger\Http\Controllers'; |
||
| 14 | |||
| 15 | |||
| 16 | 120 | public function boot() |
|
| 28 | |||
| 29 | /** |
||
| 30 | * Register the service provider. |
||
| 31 | * |
||
| 32 | * @return void |
||
| 33 | */ |
||
| 34 | 120 | View Code Duplication | public function register() |
| 35 | { |
||
| 36 | 120 | $this->mergeConfigFrom( |
|
| 37 | 120 | __DIR__.'/../../config/config.php', |
|
| 38 | 120 | $this->package |
|
| 39 | 90 | ); |
|
| 40 | |||
| 41 | |||
| 42 | $this->app['messenger'] = $this->app->share(function($app) |
||
| 43 | { |
||
| 44 | 4 | return new Message($app['config']->get('messenger'),new Client()); |
|
| 45 | 120 | }); |
|
| 46 | |||
| 47 | 120 | $this->alias(); |
|
| 48 | 90 | } |
|
| 49 | |||
| 50 | /** |
||
| 51 | * Get the services provided by the provider. |
||
| 52 | * |
||
| 53 | * @return string[] |
||
| 54 | */ |
||
| 55 | 4 | public function provides() |
|
| 59 | |||
| 60 | |||
| 61 | 120 | public function alias() { |
|
| 72 | |||
| 73 | /** |
||
| 74 | * Define the routes for the application. |
||
| 75 | * |
||
| 76 | * @param \Illuminate\Routing\Router $router |
||
| 77 | * @return void |
||
| 78 | */ |
||
| 79 | public function map(Router $router) |
||
| 86 | } |