| Conditions | 13 |
| Paths | 34 |
| Total Lines | 44 |
| Code Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | 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 |
||
| 58 | protected function __setProxyCapabilities() |
||
| 59 | { |
||
| 60 | $response = null; |
||
| 61 | |||
| 62 | foreach ($this->config as $config => $data) { |
||
| 63 | try { |
||
| 64 | if (false === empty($data)) { |
||
| 65 | switch ($config) { |
||
| 66 | case 0: // fix a weird PHP behaviour: when $config === 0 then go in 'blacklist' |
||
| 67 | break; |
||
| 68 | case 'blacklist': |
||
| 69 | $response = $this->bmp->blacklist($data); |
||
|
|
|||
| 70 | break; |
||
| 71 | case 'whitelist': |
||
| 72 | $response = $this->bmp->whitelist($data); |
||
| 73 | break; |
||
| 74 | case 'limits': |
||
| 75 | $response = $this->bmp->limits($data); |
||
| 76 | break; |
||
| 77 | case 'timeouts': |
||
| 78 | $response = $this->bmp->timeouts($data); |
||
| 79 | break; |
||
| 80 | case 'redirect': |
||
| 81 | $response = $this->bmp->remapHosts($data); |
||
| 82 | break; |
||
| 83 | case 'retry': |
||
| 84 | $response = $this->bmp->retry($data); |
||
| 85 | break; |
||
| 86 | default: |
||
| 87 | // do nothing |
||
| 88 | } |
||
| 89 | } |
||
| 90 | } catch(\Exception $e) { |
||
| 91 | throw new ModuleConfigException(__CLASS__, $e->getMessage()); |
||
| 92 | } |
||
| 93 | |||
| 94 | if (get_class($response) === 'Request') |
||
| 95 | { |
||
| 96 | if (false === $response->success) { |
||
| 97 | throw new ModuleConfigException(__CLASS__, "Proxy response error '{$reponse->status_code}' {$respone->body}"); |
||
| 98 | } |
||
| 99 | } |
||
| 100 | } |
||
| 101 | } |
||
| 102 | |||
| 104 |
This check looks for function calls that miss required arguments.