Conditions | 10 |
Paths | 48 |
Total Lines | 36 |
Code Lines | 18 |
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 |
||
23 | public function __construct(array $config = []) |
||
24 | { |
||
25 | $this->validateMemcacheConfiguration($config); |
||
26 | |||
27 | // default config |
||
28 | $this->ttl = 0; |
||
29 | |||
30 | // config |
||
31 | if (isset($config['ttl'])) { |
||
32 | $this->ttl = $config['ttl']; |
||
33 | } |
||
34 | |||
35 | $persistentId = null; |
||
36 | if (isset($config['connection_persistent']) && $config['connection_persistent']) { |
||
37 | $persistentId = '1'; |
||
38 | |||
39 | if (isset($config['pool_size']) && $config['pool_size'] > 1) { |
||
40 | $persistentId = (string) mt_rand(1, $config['pool_size']); |
||
41 | } |
||
42 | } |
||
43 | |||
44 | $this->memcached = new Memcached($persistentId); |
||
45 | $this->memcached->addServers($config['servers']); |
||
46 | |||
47 | if (isset($config['options']) && !empty($config['options'])) { |
||
48 | $this->memcached->setOptions($config['options']); |
||
|
|||
49 | } |
||
50 | |||
51 | if ($this->namespace) { |
||
52 | $this->memcached->setOption(Memcached::OPT_PREFIX_KEY, $this->namespace); |
||
53 | } |
||
54 | |||
55 | if (isset($config['cache_not_found_keys'])) { |
||
56 | $this->cacheNotFoundKeys = (bool) $config['cache_not_found_keys']; |
||
57 | } |
||
58 | } |
||
59 | |||
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.