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