| Conditions | 11 |
| Paths | 13 |
| Total Lines | 27 |
| Code Lines | 14 |
| 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 |
||
| 86 | private function getProxy($url, $protocol) |
||
| 87 | { |
||
| 88 | $url = Url::instance($url); |
||
|
|
|||
| 89 | |||
| 90 | foreach ($this->proxies as $proxy) { |
||
| 91 | if (isset($proxy['active']) && !$proxy['active']) { |
||
| 92 | continue; |
||
| 93 | } |
||
| 94 | |||
| 95 | if ($protocol !== $proxy['protocol']) { |
||
| 96 | continue; |
||
| 97 | } |
||
| 98 | |||
| 99 | $nonProxyHosts = isset($proxy['nonProxyHosts']) ? $proxy['nonProxyHosts'] : null; |
||
| 100 | if (null != $nonProxyHosts && $url->matchHost($proxy['nonProxyHosts'])) { |
||
| 101 | continue; |
||
| 102 | } |
||
| 103 | |||
| 104 | $proxyHosts = isset($proxy['proxyHosts']) ? $proxy['proxyHosts'] : null; |
||
| 105 | if (null != $proxyHosts && !$url->matchHost($proxy['proxyHosts'])) { |
||
| 106 | continue; |
||
| 107 | } |
||
| 108 | |||
| 109 | return $proxy; |
||
| 110 | } |
||
| 111 | |||
| 112 | return null; |
||
| 113 | } |
||
| 115 |