| Conditions | 13 |
| Paths | 28 |
| Total Lines | 52 |
| Code Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 119 | |||
| 120 | /** |
||
| 121 | * get route setPath method |
||
| 122 | * |
||
| 123 | * @param $path |
||
| 124 | */ |
||
| 125 | public static function setPath(callable $callback) |
||
| 126 | {
|
||
| 127 | $routeDefinitor = call_user_func($callback); |
||
| 128 | |||
| 129 | if(isset($routeDefinitor['controllerPath']) && isset($routeDefinitor['routePath'])){
|
||
| 130 | |||
| 131 | //the route paths to be saved to the mappers static property. |
||
| 132 | static::$mappers['routePaths'][] = $routeDefinitor['routePath']; |
||
| 133 | static::$mappers['controllerNamespaces'][] = Utils::getNamespace($routeDefinitor['controllerPath']); |
||
| 134 | |||
| 135 | // if there is endpoint, |
||
| 136 | // then only that endpoint is transferred into the path |
||
| 137 | if(defined('endpoint')){
|
||
| 138 | |||
| 139 | $routeName = endpoint.'Route.php'; |
||
| 140 | $routeMapper = $routeDefinitor['routePath'].''.DIRECTORY_SEPARATOR.''.$routeName; |
||
| 141 | |||
| 142 | if(file_exists($routeMapper) && !isset(static::$paths[$routeMapper])){
|
||
| 143 | static::$paths[$routeMapper] = $routeDefinitor['controllerPath']; |
||
| 144 | } |
||
| 145 | } |
||
| 146 | else{
|
||
| 147 | |||
| 148 | // if there is no endpoint, |
||
| 149 | // all files in the path of the route are transferred to path. |
||
| 150 | $allFilesInThatRoutePath = Utils::glob($routeDefinitor['routePath']); |
||
| 151 | |||
| 152 | foreach ($allFilesInThatRoutePath as $item){
|
||
| 153 | static::$paths[$item] = $routeDefinitor['controllerPath']; |
||
| 154 | } |
||
| 155 | } |
||
| 156 | } |
||
| 157 | } |
||
| 158 | |||
| 159 | /** |
||
| 160 | * get route setRoute method |
||
| 161 | * |
||
| 162 | * @param $params |
||
| 163 | * @param $function |
||
| 164 | * @param null $controller |
||
|
|
|||
| 165 | */ |
||
| 166 | public static function setRoute($params,$function,$controller=null) |
||
| 167 | {
|
||
| 168 | [$pattern,$route] = $params; |
||
| 169 | [$class,$method] = explode("@",$route);
|
||
| 170 | |||
| 171 | $patternList = array_values( |
||
| 198 | } |