| Conditions | 14 |
| Paths | 9 |
| Total Lines | 24 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 112 | protected function validateMemcacheConfiguration(array $config) |
||
| 113 | { |
||
| 114 | if (!array_key_exists('servers', $config)) { |
||
| 115 | throw new InvalidConfigurationException('Missing configuration parameter: servers'); |
||
| 116 | } |
||
| 117 | |||
| 118 | if (!is_array($config['servers'])) { |
||
| 119 | throw new InvalidConfigurationException('Invalid configuration parameter: servers'); |
||
| 120 | } |
||
| 121 | |||
| 122 | foreach ($config['servers'] as $server) { |
||
| 123 | if (!is_array($server) || count($server) < 2 || count($server) > 3 || !is_numeric($server[1]) || (isset($server[2]) && !is_numeric($server[2]))) { |
||
| 124 | throw new InvalidConfigurationException('Invalid configuration parameter: servers'); |
||
| 125 | } |
||
| 126 | } |
||
| 127 | |||
| 128 | if (array_key_exists('options', $config) && !is_array($config['options'])) { |
||
| 129 | throw new InvalidConfigurationException('Invalid configuration parameter: options'); |
||
| 130 | } |
||
| 131 | |||
| 132 | if (isset($config['ttl']) && !is_numeric($config['ttl'])) { |
||
| 133 | throw new InvalidConfigurationException('Invalid configuration parameter: ttl'); |
||
| 134 | } |
||
| 135 | } |
||
| 136 | } |
||
| 137 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.