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 |
||
| 8 | class RouteServiceProvider extends AbstractRouteServiceProvider |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * The compatibility version of this RouteServiceProvider. |
||
| 12 | * |
||
| 13 | * @var string |
||
| 14 | */ |
||
| 15 | protected $compatibilityVersion = 'Edge'; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Register all the Flare Provided Middleware and Middleware Groups. |
||
| 19 | * |
||
| 20 | * We define flarebase rather than extend an existing middleware stack |
||
| 21 | * since it is possible that a user has amended the default middleware |
||
| 22 | * of their application in a way that could break Flare. |
||
| 23 | * |
||
| 24 | * @param Router $router |
||
| 25 | */ |
||
| 26 | protected function registerMiddleware(Router $router) |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Register the Defined Routes. |
||
| 49 | * |
||
| 50 | * This registers all the routes which have been defined by |
||
| 51 | * Admin sections defined in the Application's Flare Config |
||
| 52 | * (or in the runtime config if anotehr service provider |
||
| 53 | * has already started manipulating these dynamically). |
||
| 54 | * |
||
| 55 | * @param Router $router |
||
| 56 | */ |
||
| 57 | View Code Duplication | protected function registerDefinedRoutes(Router $router) |
|
| 71 | |||
| 72 | /** |
||
| 73 | * Register the Default Routes. |
||
| 74 | * |
||
| 75 | * This registers all the default routes which are included |
||
| 76 | * with Flare. These consist of things which will probably |
||
| 77 | * be included with every application such as the login, |
||
| 78 | * logout and password reset forms. |
||
| 79 | * |
||
| 80 | * The login form can however be hidden by setting the |
||
| 81 | * 'show' config for 'login' to false. |
||
| 82 | * |
||
| 83 | * @param Router $router |
||
| 84 | */ |
||
| 85 | protected function registerDefaultRoutes(Router $router) |
||
| 113 | } |
||
| 114 |