| Conditions | 11 |
| Paths | 1024 |
| Total Lines | 13 |
| Code Lines | 11 |
| 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 |
||
| 109 | protected function unparse_url(array $parsed_url): string |
||
| 110 | { |
||
| 111 | $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
||
| 112 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
||
| 113 | $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
||
| 114 | $user = isset($parsed_url['user']) ? $parsed_url['user'] : ''; |
||
| 115 | $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : ''; |
||
| 116 | $pass = ($user || $pass) ? "$pass@" : ''; |
||
| 117 | $path = isset($parsed_url['path']) ? $parsed_url['path'] : ''; |
||
| 118 | $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
||
| 119 | $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
||
| 120 | return $scheme . $user . $pass . $host . $port . $path . $query . $fragment; |
||
| 121 | } |
||
| 122 | |||
| 123 | } |