Conditions | 10 |
Paths | 193 |
Total Lines | 15 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 2 |
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 |
||
56 | public function __toString(){ |
||
57 | if ($this->_parsed) { |
||
58 | $d = []; |
||
59 | if ($this->scheme) $d[] = "{$this->scheme}://"; |
||
60 | if ($this->user) $d[] = "{$this->user}" . (empty($this->pass)?'':":{$this->pass}") . "@"; |
||
61 | if ($this->host) $d[] = "{$this->host}"; |
||
62 | if ($this->port) $d[] = ":{$this->port}"; |
||
63 | if ($this->path) $d[] = "/" . ltrim($this->path,"/"); |
||
64 | if (!empty($this->query)) $d[] = "?" . http_build_query($this->query); |
||
65 | if ($this->fragment) $d[] = "#{$this->fragment}"; |
||
66 | return implode('', $d); |
||
67 | } else { |
||
68 | return $this->_origin; |
||
69 | } |
||
70 | } |
||
71 | |||
73 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.