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 |
||
116 | protected function validateMemcacheConfiguration(array $config) |
||
117 | { |
||
118 | if (!array_key_exists('servers', $config)) { |
||
119 | throw new InvalidConfigurationException('Missing configuration parameter: servers'); |
||
120 | } |
||
121 | |||
122 | if (!is_array($config['servers'])) { |
||
123 | throw new InvalidConfigurationException('Invalid configuration parameter: servers'); |
||
124 | } |
||
125 | |||
126 | foreach ($config['servers'] as $server) { |
||
127 | if (!is_array($server) || count($server) < 2 || count($server) > 3 || !is_numeric($server[1]) || (isset($server[2]) && !is_numeric($server[2]))) { |
||
128 | throw new InvalidConfigurationException('Invalid configuration parameter: servers'); |
||
129 | } |
||
130 | } |
||
131 | |||
132 | if (array_key_exists('options', $config) && !is_array($config['options'])) { |
||
133 | throw new InvalidConfigurationException('Invalid configuration parameter: options'); |
||
134 | } |
||
135 | |||
136 | if (isset($config['ttl']) && !is_numeric($config['ttl'])) { |
||
137 | throw new InvalidConfigurationException('Invalid configuration parameter: ttl'); |
||
138 | } |
||
139 | } |
||
140 | |||
147 |
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.