| Conditions | 12 |
| Paths | 2048 |
| Total Lines | 16 |
| Code Lines | 12 |
| 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 |
||
| 92 | private function buildUrl(array $url, array $params = array()) |
||
| 93 | { |
||
| 94 | ksort($params, SORT_STRING); |
||
| 95 | $url['query'] = http_build_query($params, '', '&'); |
||
| 96 | |||
| 97 | $scheme = isset($url['scheme']) ? $url['scheme'].'://' : ''; |
||
| 98 | $host = isset($url['host']) ? $url['host'] : ''; |
||
| 99 | $port = isset($url['port']) ? ':'.$url['port'] : ''; |
||
| 100 | $user = isset($url['user']) ? $url['user'] : ''; |
||
| 101 | $pass = isset($url['pass']) ? ':'.$url['pass'] : ''; |
||
| 102 | $pass = ($user || $pass) ? "$pass@" : ''; |
||
| 103 | $path = isset($url['path']) ? $url['path'] : ''; |
||
| 104 | $query = isset($url['query']) && $url['query'] ? '?'.$url['query'] : ''; |
||
| 105 | $fragment = isset($url['fragment']) ? '#'.$url['fragment'] : ''; |
||
| 106 | |||
| 107 | return $scheme.$user.$pass.$host.$port.$path.$query.$fragment; |
||
| 108 | } |
||
| 110 |