| Conditions | 9 |
| Paths | 56 |
| Total Lines | 62 |
| Code Lines | 35 |
| 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 |
||
| 67 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 68 | { |
||
| 69 | $searchPath = $input->getArgument('path'); |
||
| 70 | |||
| 71 | if (substr($input->getArgument('path'), -1, 1) === '/') { |
||
| 72 | $searchPath .= '*'; |
||
| 73 | } |
||
| 74 | |||
| 75 | $this->_collection->addFieldToFilter('path', array( |
||
| 76 | 'like' => str_replace('*', '%', $searchPath) |
||
| 77 | )); |
||
| 78 | |||
| 79 | if ($scopeId = $input->getOption('scope')) { |
||
| 80 | $this->_collection->addFieldToFilter( |
||
| 81 | 'scope', |
||
| 82 | array( |
||
| 83 | 'eq' => $scopeId |
||
| 84 | ) |
||
| 85 | ); |
||
| 86 | } |
||
| 87 | |||
| 88 | if ($scopeId = $input->getOption('scope-id')) { |
||
| 89 | $this->_collection->addFieldToFilter( |
||
| 90 | 'scope_id', |
||
| 91 | array( |
||
| 92 | 'eq' => $scopeId |
||
| 93 | ) |
||
| 94 | ); |
||
| 95 | } |
||
| 96 | |||
| 97 | $this->_collection->addOrder('path', 'ASC'); |
||
| 98 | |||
| 99 | // sort according to the config overwrite order |
||
| 100 | // trick to force order default -> (f)website -> store , because f comes after d and before s |
||
| 101 | $this->_collection->addOrder('REPLACE(scope, "website", "fwebsite")', 'ASC'); |
||
| 102 | |||
| 103 | $this->_collection->addOrder('scope_id', 'ASC'); |
||
| 104 | |||
| 105 | if ($this->_collection->count() == 0) { |
||
| 106 | $output->writeln(sprintf("Couldn't find a config value for \"%s\"", $input->getArgument('path'))); |
||
| 107 | return; |
||
| 108 | } |
||
| 109 | |||
| 110 | foreach ($this->_collection as $item) { |
||
| 111 | $table[] = array( |
||
| 112 | 'path' => $item->getPath(), |
||
| 113 | 'scope' => $item->getScope(), |
||
| 114 | 'scope_id' => $item->getScopeId(), |
||
| 115 | 'value' => $this->_formatValue($item->getValue(), ($input->getOption('decrypt') ? 'decrypt' : false)), |
||
| 116 | ); |
||
| 117 | } |
||
| 118 | |||
| 119 | ksort($table); |
||
| 120 | |||
| 121 | if ($input->getOption('update-script')) { |
||
| 122 | $this->renderAsUpdateScript($output, $table); |
||
| 123 | } elseif ($input->getOption('magerun-script')) { |
||
| 124 | $this->renderAsMagerunScript($output, $table); |
||
| 125 | } else { |
||
| 126 | $this->renderAsTable($output, $table, $input->getOption('format')); |
||
| 127 | } |
||
| 128 | } |
||
| 129 | |||
| 200 |
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.