| Conditions | 14 |
| Paths | 1025 |
| Total Lines | 25 |
| 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 |
||
| 31 | protected function unparseUrl($parsed_url) |
||
| 32 | { |
||
| 33 | if (empty($parsed_url)) { |
||
| 34 | return ''; |
||
| 35 | } |
||
| 36 | |||
| 37 | $url = ''; |
||
| 38 | $url .= isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
||
| 39 | $url .= $parsed_url['host'] ?? ''; |
||
| 40 | $url .= isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
||
| 41 | $user = $parsed_url['user'] ?? ''; |
||
| 42 | $pass = isset($parsed_url['pass']) ? ':'.$parsed_url['pass'] : ''; |
||
| 43 | $url .= $user.(($user || $pass) ? "{$pass}@" : ''); |
||
| 44 | |||
| 45 | if (! empty($url)) { |
||
| 46 | $url .= isset($parsed_url['path']) ? '/'.ltrim($parsed_url['path'], '/').(config('cortex.foundation.route.trailing_slash') ? '/' : '') : ''; |
||
| 47 | } else { |
||
| 48 | $url .= isset($parsed_url['path']) ? $parsed_url['path'].(config('cortex.foundation.route.trailing_slash') ? '/' : '') : ''; |
||
| 49 | } |
||
| 50 | |||
| 51 | $url .= isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
||
| 52 | $url .= isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
||
| 53 | |||
| 54 | return $url; |
||
| 55 | } |
||
| 56 | } |
||
| 57 |