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 |
||
| 11 | { |
||
| 12 | $this->items = $this->parseRoutes($routes, $filter, $namespace); |
||
| 13 | } |
||
| 14 | /** |
||
| 15 | * Parse the routes into a jsonable output. |
||
| 16 | * |
||
| 17 | * @param RouteCollection $routes |
||
| 18 | * @param string $filter |
||
| 19 | * @param string $namespace |
||
| 20 | * |
||
| 21 | * @return array |
||
| 22 | * @throws ZeroRoutesException |
||
| 23 | */ |
||
| 24 | protected function parseRoutes(RouteCollection $routes, $filter, $namespace) |
||
| 33 | /** |
||
| 34 | * Throw an exception if there aren't any routes to process |
||
| 35 | * |
||
| 36 | * @param RouteCollection $routes |
||
| 37 | * |
||
| 38 | * @throws ZeroRoutesException |
||
| 39 | */ |
||
| 40 | protected function guardAgainstZeroRoutes(RouteCollection $routes) |
||
| 46 | /** |
||
| 47 | * Get the route information for a given route. |
||
| 48 | * |
||
| 49 | * @param $route \Illuminate\Routing\Route |
||
| 50 | * @param $filter string |
||
| 51 | * @param $namespace string |
||
| 52 | * |
||
| 53 | * @return array |
||
| 54 | */ |
||
| 55 | protected function getRouteInformation(Route $route, $filter, $namespace) |
||
| 79 | } |
||
| 80 |