| Conditions | 26 |
| Paths | 70 |
| Total Lines | 42 |
| Code Lines | 33 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 82 | private function setParameters(ContainerBuilder $container, $checkName, $group, $values) |
||
| 83 | { |
||
| 84 | $prefix = sprintf('%s.check.%s', $this->getAlias(), $checkName); |
||
| 85 | switch ($checkName) { |
||
| 86 | case 'class_exists': |
||
| 87 | case 'cpu_performance': |
||
| 88 | case 'php_extensions': |
||
| 89 | case 'php_version': |
||
| 90 | case 'php_flags': |
||
| 91 | case 'readable_directory': |
||
| 92 | case 'writable_directory': |
||
| 93 | case 'process_running': |
||
| 94 | case 'doctrine_dbal': |
||
| 95 | case 'http_service': |
||
| 96 | case 'guzzle_http_service': |
||
| 97 | case 'memcache': |
||
| 98 | case 'redis': |
||
| 99 | case 'rabbit_mq': |
||
| 100 | case 'stream_wrapper_exists': |
||
| 101 | case 'file_ini': |
||
| 102 | case 'file_json': |
||
| 103 | case 'file_xml': |
||
| 104 | case 'file_yaml': |
||
| 105 | case 'expressions': |
||
| 106 | $container->setParameter($prefix.'.'.$group, $values); |
||
| 107 | continue; |
||
| 108 | |||
| 109 | case 'symfony_version': |
||
| 110 | continue; |
||
| 111 | |||
| 112 | case 'opcache_memory': |
||
| 113 | if (!class_exists('ZendDiagnostics\Check\OpCacheMemory')) { |
||
| 114 | throw new \InvalidArgumentException('Please require at least "v1.0.4" of "ZendDiagnostics"'); |
||
| 115 | } |
||
| 116 | } |
||
| 117 | |||
| 118 | if (is_array($values)) { |
||
| 119 | foreach ($values as $key => $value) { |
||
| 120 | $container->setParameter($prefix.'.'.$key.'.'.$group, $value); |
||
| 121 | } |
||
| 122 | } |
||
| 123 | } |
||
| 124 | } |
||
| 125 |