Conditions | 16 |
Paths | > 20000 |
Total Lines | 38 |
Code Lines | 26 |
Lines | 0 |
Ratio | 0 % |
Changes | 6 | ||
Bugs | 2 | Features | 1 |
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 |
||
29 | public function factory(InputInterface $input) { |
||
30 | |||
31 | $config = new Configuration(); |
||
32 | |||
33 | $treeBuilder = new TreeBuilder(); |
||
34 | $hydrator = new Hydrator(new Validator($treeBuilder->getTree())); |
||
35 | |||
36 | // first, load config file |
||
37 | $locator = new ConfigLocator(); |
||
38 | $filename = $locator->locate($input->getOption('config')); |
||
39 | |||
40 | if(null !== $filename) { |
||
41 | $loader = new Loader($hydrator); |
||
42 | $config = $loader->load($filename); |
||
43 | } else { |
||
44 | $config = $hydrator->hydrates($config, array()); |
||
45 | } |
||
46 | |||
47 | |||
48 | // then, overwrite configuration by arguments provided in run |
||
49 | strlen($input->getArgument('path')) > 0 && $config->getPath()->setBasePath($input->getArgument('path')); |
||
50 | strlen($input->getOption('extensions')) > 0 && $config->getPath()->setExtensions($input->getOption('extensions')); |
||
51 | strlen($input->getOption('excluded-dirs')) > 0 && $config->getPath()->setExcludedDirs($input->getOption('excluded-dirs')); |
||
52 | strlen($input->getOption('symlinks')) > 0 && $config->getPath()->setFollowSymlinks(true); |
||
53 | strlen($input->getOption('report-xml')) > 0 && $config->getLogging()->setReport('xml', $input->getOption('report-xml')); |
||
54 | strlen($input->getOption('report-cli')) > 0 && $config->getLogging()->setReport('cli', $input->getOption('report-cli')); |
||
55 | strlen($input->getOption('report-json')) > 0 && $config->getLogging()->setReport('json', $input->getOption('report-json')); |
||
56 | strlen($input->getOption('report-html')) > 0 && $config->getLogging()->setReport('html', $input->getOption('report-html')); |
||
57 | strlen($input->getOption('report-csv')) > 0 && $config->getLogging()->setReport('csv', $input->getOption('report-csv')); |
||
58 | strlen($input->getOption('violations-xml')) > 0 && $config->getLogging()->setViolation('xml', $input->getOption('violations-xml')); |
||
59 | strlen($input->getOption('chart-bubbles')) > 0 && $config->getLogging()->setChart('bubbles', $input->getOption('chart-bubbles')); |
||
60 | strlen($input->getOption('failure-condition')) > 0 && $config->setFailureCondition($input->getOption('failure-condition')); |
||
61 | strlen($input->getOption('template-title')) > 0 && $config->getTemplate()->setTitle($input->getOption('template-title')); |
||
62 | strlen($input->getOption('ignore-errors')) > 0 && $config->setIgnoreErrors(true); |
||
63 | |||
64 | return $config; |
||
65 | |||
66 | } |
||
67 | } |