Conditions | 12 |
Paths | 20 |
Total Lines | 48 |
Code Lines | 34 |
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 |
||
36 | protected function execute(InputInterface $input, OutputInterface $output) |
||
37 | { |
||
38 | $this->detectMagento($output, true); |
||
39 | if ($this->initMagento()) { |
||
40 | $table = new \Zend_Text_Table(array('columnWidths' => array(8, 30, 60, 60))); |
||
41 | $tableData = array(); |
||
42 | if ($this->initMagento()) { |
||
43 | $time = microtime(true); |
||
44 | $rewrites = $this->loadRewrites(); |
||
45 | $conflictCounter = 0; |
||
46 | foreach ($rewrites as $type => $data) { |
||
47 | if (count($data) > 0 && is_array($data)) { |
||
48 | foreach ($data as $class => $rewriteClass) { |
||
49 | if (count($rewriteClass) > 1) { |
||
50 | if ($this->_isInheritanceConflict($rewriteClass)) { |
||
51 | $tableData[] = array( |
||
52 | 'Type' => $type, |
||
53 | 'Class' => $class, |
||
54 | 'Rewrites' => implode(', ', $rewriteClass), |
||
55 | 'Loaded Class' => $this->_getLoadedClass($type, $class), |
||
56 | ); |
||
57 | $conflictCounter++; |
||
58 | } |
||
59 | } |
||
60 | } |
||
61 | } |
||
62 | } |
||
63 | |||
64 | if ($input->getOption('log-junit')) { |
||
65 | $this->logJUnit($tableData, $input->getOption('log-junit'), microtime($time) - $time); |
||
66 | } else { |
||
67 | if ($conflictCounter > 0) { |
||
68 | array_map(array($table, 'appendRow'), $tableData); |
||
69 | $output->write($table->render()); |
||
70 | $message = sprintf( |
||
71 | '%d %s found!', |
||
72 | $conflictCounter, |
||
73 | $conflictCounter == 1 ? 'conflict was' : 'conflicts were' |
||
74 | ); |
||
75 | $output->writeln('<error>' . $message . '</error>'); |
||
76 | return 1; |
||
77 | } else { |
||
78 | $output->writeln('<info>No rewrite conflicts were found.</info>'); |
||
79 | } |
||
80 | } |
||
81 | } |
||
82 | } |
||
83 | } |
||
84 | |||
188 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.