| Conditions | 15 |
| Paths | 2561 |
| Total Lines | 21 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 2 | Features | 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 |
||
| 15 | public static function unparseUrl($parsed_url) |
||
| 16 | { |
||
| 17 | if (empty($parsed_url)) { |
||
| 18 | return ''; |
||
| 19 | } |
||
| 20 | $url = ''; |
||
| 21 | $url .= isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
||
| 22 | $url .= isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
||
| 23 | $url .= isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
||
| 24 | $user = isset($parsed_url['user']) ? $parsed_url['user'] : ''; |
||
| 25 | $pass = isset($parsed_url['pass']) ? ':'.$parsed_url['pass'] : ''; |
||
| 26 | $url .= $user.(($user || $pass) ? "$pass@" : ''); |
||
| 27 | if (! empty($url)) { |
||
| 28 | $url .= isset($parsed_url['path']) ? '/'.ltrim($parsed_url['path'], '/') : ''; |
||
| 29 | } elseif (empty($url)) { |
||
| 30 | $url .= isset($parsed_url['path']) ? $parsed_url['path'] : ''; |
||
| 31 | } |
||
| 32 | $url .= isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
||
| 33 | $url .= isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
||
| 34 | |||
| 35 | return $url; |
||
| 36 | } |
||
| 109 |