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 |
||
| 7 | trait RouterModifierTrait { |
||
| 8 | /** |
||
| 9 | * |
||
| 10 | * @param string $path |
||
| 11 | * @param string $controller |
||
| 12 | * @param string $action |
||
| 13 | * @param array|null $methods |
||
| 14 | * @param string $name |
||
| 15 | * @param boolean $cache |
||
| 16 | * @param int $duration |
||
| 17 | * @param array $requirements |
||
| 18 | */ |
||
| 19 | public static function addRoute($path, $controller, $action = "index", $methods = null, $name = "", $cache = false, $duration = null, $requirements = []) { |
||
| 22 | |||
| 23 | public static function addRouteToRoutes(&$routesArray, $path, $controller, $action = "index", $methods = null, $name = "", $cache = false, $duration = null, $requirements = []) { |
||
| 29 | |||
| 30 | private static function _addRoute($method,&$routesArray, $path, $controller, $action = "index", $methods = null, $name = "", $cache = false, $duration = null, $requirements = []){ |
||
| 37 | |||
| 38 | public static function addRoutesToRoutes(&$routesArray, $paths, $controller, $action = "index", $methods = null, $name = "", $cache = false, $duration = null, $requirements = []) { |
||
| 46 | } |
||
| 47 | |||
| 48 |