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