Conditions | 6 |
Paths | 17 |
Total Lines | 51 |
Lines | 25 |
Ratio | 49.02 % |
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 |
||
61 | protected function execute(InputInterface $input, OutputInterface $output) |
||
62 | { |
||
63 | $style = new DiffStyle($input, $output); |
||
64 | $style->title($this->getApplication()->getLongVersion()); |
||
65 | |||
66 | |||
67 | $parser = new JUnitParser(); |
||
68 | $merger = new JUnitMerger(new MergeResult($style)); |
||
69 | try { |
||
70 | $mergeResult = $merger->merge( |
||
71 | $parser->parseFile($input->getArgument('base')), |
||
|
|||
72 | $parser->parseFile($input->getArgument('current')) |
||
73 | ); |
||
74 | } catch (\Exception $e) { |
||
75 | $style->error($e->getMessage()); |
||
76 | return; |
||
77 | } |
||
78 | |||
79 | if ($output->getVerbosity() >= Output::VERBOSITY_NORMAL) { |
||
80 | $writer = new Standard($style, $output->getVerbosity()); |
||
81 | $writer->write($mergeResult); |
||
82 | } |
||
83 | |||
84 | View Code Duplication | if ($output->getVerbosity() >= Output::VERBOSITY_VERBOSE) { |
|
85 | $writer = new Legend( |
||
86 | $style, |
||
87 | basename($input->getArgument('base')), |
||
88 | basename($input->getArgument('current')) |
||
89 | ); |
||
90 | $writer->write($mergeResult); |
||
91 | } |
||
92 | |||
93 | View Code Duplication | if ($output->getVerbosity() >= Output::VERBOSITY_QUIET) { |
|
94 | $writer = new FileSummary( |
||
95 | $style, |
||
96 | basename($input->getArgument('base')), |
||
97 | basename($input->getArgument('current')) |
||
98 | ); |
||
99 | |||
100 | $writer->write($mergeResult); |
||
101 | } |
||
102 | |||
103 | View Code Duplication | if ($output->getVerbosity() >= Output::VERBOSITY_QUIET) { |
|
104 | $writer = new Summary( |
||
105 | $style, |
||
106 | basename($input->getArgument('base')), |
||
107 | basename($input->getArgument('current')) |
||
108 | ); |
||
109 | $writer->write($mergeResult); |
||
110 | } |
||
111 | } |
||
112 | } |
||
113 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.