| Conditions | 11 | 
| Paths | 35 | 
| Total Lines | 32 | 
| Code Lines | 21 | 
| 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 | ||
| 36 | public function add($line) | ||
| 37 |     { | ||
| 38 |         if (($parsed = parse_url(($line = $this->urlEncode(mb_strtolower($line))))) === false) { | ||
| 39 | return false; | ||
| 40 | } | ||
| 41 | $line = isset($parsed['host']) ? $parsed['host'] : $parsed['path']; | ||
| 42 | if ( | ||
| 43 | !$this->urlValidateHost($line) || | ||
| 44 | ( | ||
| 45 | isset($parsed['scheme']) && | ||
| 46 | !$this->urlValidateScheme($parsed['scheme']) | ||
| 47 | ) | ||
| 48 |         ) { | ||
| 49 | return false; | ||
| 50 | } | ||
| 51 | $scheme = isset($parsed['scheme']) ? $parsed['scheme'] . '://' : ''; | ||
| 52 | $port = isset($parsed['port']) ? ':' . $parsed['port'] : ''; | ||
| 53 | |||
| 54 | $host = $scheme . $line . $port; | ||
| 55 |         if (in_array($host, $this->array)) { | ||
| 56 | return false; | ||
| 57 | } | ||
| 58 |         if ($this->parent !== null) { | ||
| 59 | $this->array[] = $host; | ||
| 60 | return true; | ||
| 61 | } | ||
| 62 |         if (!empty($this->array)) { | ||
| 63 | return false; | ||
| 64 | } | ||
| 65 | $this->array = [$host]; | ||
| 66 | return true; | ||
| 67 | } | ||
| 68 | |||
| 103 |