| Conditions | 11 | 
| Paths | 384 | 
| Total Lines | 62 | 
| Code Lines | 30 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | 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  | 
            ||
| 41 | 	public static function url_parser($url) { | 
            ||
| 42 | |||
| 43 | // multiple /// messes up parse_url, replace 3 or more with 2  | 
            ||
| 44 | 		$url = preg_replace('/(\/{2,})/','//',$url); | 
            ||
| 45 | |||
| 46 | $parse_url = parse_url($url);  | 
            ||
| 47 | |||
| 48 | 		if(empty($parse_url["scheme"])) { | 
            ||
| 49 | $parse_url["scheme"] = "http";  | 
            ||
| 50 | }  | 
            ||
| 51 | 		if(empty($parse_url["host"]) && !empty($parse_url["path"])) { | 
            ||
| 52 | // Strip slash from the beginning of path  | 
            ||
| 53 | $parse_url["host"] = ltrim($parse_url["path"], '\/');  | 
            ||
| 54 | $parse_url["path"] = "";  | 
            ||
| 55 | }  | 
            ||
| 56 | |||
| 57 | 		$url_array = array("url" => "", "url_display" => ""); | 
            ||
| 58 | |||
| 59 | // Check if scheme is correct  | 
            ||
| 60 | 		if(!in_array($parse_url["scheme"], array("http", "https", "gopher"))) { | 
            ||
| 61 | $url_array["url"] .= 'http'.'://';  | 
            ||
| 62 | 		} else { | 
            ||
| 63 | $url_array["url"] .= $parse_url["scheme"].'://';  | 
            ||
| 64 | }  | 
            ||
| 65 | |||
| 66 | // Check if the right amount of "www" is set.  | 
            ||
| 67 | 		$explode_host = explode(".", $parse_url["host"]); | 
            ||
| 68 | |||
| 69 | // Remove empty entries  | 
            ||
| 70 | $explode_host = array_filter($explode_host);  | 
            ||
| 71 | // And reassign indexes  | 
            ||
| 72 | $explode_host = array_values($explode_host);  | 
            ||
| 73 | |||
| 74 | // Contains subdomain  | 
            ||
| 75 | 		if(count($explode_host) > 2) { | 
            ||
| 76 | // Check if subdomain only contains the letter w(then not any other subdomain).  | 
            ||
| 77 | 			if(substr_count($explode_host[0], 'w') == strlen($explode_host[0])) { | 
            ||
| 78 | // Replace with "www" to avoid "ww" or "wwww", etc.  | 
            ||
| 79 | $explode_host[0] = "www";  | 
            ||
| 80 | |||
| 81 | }  | 
            ||
| 82 | }  | 
            ||
| 83 | |||
| 84 | 		$url_array["url"] .= implode(".",$explode_host); | 
            ||
| 85 | 		$url_array["url_display"] = trim(implode(".",$explode_host), '\/'); // Removes trailing slash | 
            ||
| 86 | |||
| 87 | 		if(!empty($parse_url["port"])) { | 
            ||
| 88 | $url_array["url"] .= ":".$parse_url["port"];  | 
            ||
| 89 | }  | 
            ||
| 90 | 		if(!empty($parse_url["path"])) { | 
            ||
| 91 | $url_array["url"] .= $parse_url["path"];  | 
            ||
| 92 | }  | 
            ||
| 93 | 		if(!empty($parse_url["query"])) { | 
            ||
| 94 | $url_array["url"] .= '?'.$parse_url["query"];  | 
            ||
| 95 | }  | 
            ||
| 96 | 		if(!empty($parse_url["fragment"])) { | 
            ||
| 97 | $url_array["url"] .= '#'.$parse_url["fragment"];  | 
            ||
| 98 | }  | 
            ||
| 99 | |||
| 100 | |||
| 101 | return $url_array;  | 
            ||
| 102 | }  | 
            ||
| 103 | |||
| 154 | }  | 
            
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.