Conditions | 1 |
Paths | 1 |
Total Lines | 98 |
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 |
||
203 | private function getIndexesNode() |
||
204 | { |
||
205 | $builder = new TreeBuilder(); |
||
206 | $node = $builder->root('indexes'); |
||
207 | |||
208 | $node |
||
209 | // ->isRequired() |
||
210 | // ->requiresAtLeastOneElement() |
||
211 | ->useAttributeAsKey('name') |
||
212 | ->info('Creates index service for the specific document. The configuration key is the index name.') |
||
213 | ->prototype('array') |
||
214 | ->children() |
||
215 | ->arrayNode('hosts') |
||
216 | ->info('Defines hosts to connect to.') |
||
217 | ->defaultValue(['127.0.0.1:9200']) |
||
218 | ->prototype('scalar')->end() |
||
219 | ->end() |
||
220 | |||
221 | ->scalarNode('mapping') |
||
222 | ->info('Namespace of the elasticsearch index/type document class.') |
||
223 | ->isRequired() |
||
224 | ->end() |
||
225 | |||
226 | ->arrayNode('settings') |
||
227 | ->defaultValue( |
||
228 | [ |
||
229 | 'number_of_replicas' => 0, |
||
230 | 'number_of_shards' => 1, |
||
231 | 'refresh_interval' => -1, |
||
232 | ] |
||
233 | ) |
||
234 | ->info('Sets index settings for connection.') |
||
235 | ->prototype('variable')->end() |
||
236 | ->end() |
||
237 | |||
238 | ->booleanNode('force_commit') |
||
239 | ->info('Forces commit to the elasticsearch on kernel terminate event.') |
||
240 | ->defaultTrue() |
||
241 | ->end() |
||
242 | |||
243 | ->integerNode('bulk_size') |
||
244 | ->min(0) |
||
245 | ->defaultValue(100) |
||
246 | ->info( |
||
247 | 'Maximum documents size in the bulk container. ' . |
||
248 | 'When the limit is reached it will auto-commit.' |
||
249 | ) |
||
250 | ->end() |
||
251 | |||
252 | ->enumNode('commit_mode') |
||
253 | ->values(['refresh', 'flush', 'none']) |
||
254 | ->defaultValue('refresh') |
||
255 | ->info( |
||
256 | 'The default type of commit for bulk queries.' |
||
257 | ) |
||
258 | ->end() |
||
259 | |||
260 | ->arrayNode('logger') |
||
261 | ->info('Enables elasticsearch queries logging') |
||
262 | ->addDefaultsIfNotSet() |
||
263 | ->beforeNormalization() |
||
264 | ->ifTrue( |
||
265 | function ($v) { |
||
266 | return is_bool($v); |
||
267 | } |
||
268 | ) |
||
269 | ->then( |
||
270 | function ($v) { |
||
271 | return ['enabled' => $v]; |
||
272 | } |
||
273 | )->end() |
||
274 | ->children() |
||
275 | ->booleanNode('enabled') |
||
276 | ->info('enables logging') |
||
277 | ->defaultFalse() |
||
278 | ->end() |
||
279 | ->scalarNode('level') |
||
280 | ->info('Sets PSR logging level.') |
||
281 | ->defaultValue(LogLevel::WARNING) |
||
282 | ->validate() |
||
283 | ->ifNotInArray((new \ReflectionClass('Psr\Log\LogLevel'))->getConstants()) |
||
284 | ->thenInvalid('Invalid PSR log level.') |
||
285 | ->end() |
||
286 | ->end() |
||
287 | ->scalarNode('log_file_name') |
||
288 | ->info('Log filename. The default name is the index name.') |
||
289 | ->defaultValue(null)->end() |
||
290 | ->end() |
||
291 | ->end() |
||
292 | |||
293 | ->end() |
||
294 | ->end() |
||
295 | ->end() |
||
296 | |||
297 | ; |
||
298 | |||
299 | return $node; |
||
300 | } |
||
301 | } |
||
302 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.