Conditions | 9 |
Paths | 192 |
Total Lines | 59 |
Lines | 7 |
Ratio | 11.86 % |
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 |
||
47 | protected function execute(InputInterface $input, OutputInterface $output) |
||
48 | { |
||
49 | $this->detectMagento($output); |
||
50 | |||
51 | $softInitMode = in_array($input->getArgument('key'), array( |
||
52 | 'version', |
||
53 | 'edition', |
||
54 | )); |
||
55 | |||
56 | if ($input->getOption('format') == null && $input->getArgument('key') == null) { |
||
|
|||
57 | $this->writeSection($output, 'Magento System Information'); |
||
58 | } |
||
59 | |||
60 | $this->initMagento($softInitMode); |
||
61 | |||
62 | $this->infos['Version'] = $this->magentoVersion(); |
||
63 | $this->infos['Edition'] = ($this->_magentoEnterprise ? 'Enterprise' : 'Community'); |
||
64 | $this->infos['Root'] = $this->_magentoRootFolder; |
||
65 | |||
66 | if ($softInitMode === false) { |
||
67 | $config = \Mage::app()->getConfig(); |
||
68 | $this->addCacheInfos(); |
||
69 | |||
70 | $this->infos['Session'] = $config->getNode('global/session_save'); |
||
71 | |||
72 | $this->infos['Crypt Key'] = $config->getNode('global/crypt/key'); |
||
73 | $this->infos['Install Date'] = $config->getNode('global/install/date'); |
||
74 | try { |
||
75 | $this->findCoreOverwrites(); |
||
76 | $this->findVendors(); |
||
77 | $this->attributeCount(); |
||
78 | $this->customerCount(); |
||
79 | $this->categoryCount(); |
||
80 | $this->productCount(); |
||
81 | } catch (Exception $e) { |
||
82 | $output->writeln('<error>' . $e->getMessage() . '</error>'); |
||
83 | } |
||
84 | } |
||
85 | |||
86 | $table = array(); |
||
87 | foreach ($this->infos as $key => $value) { |
||
88 | $table[] = array($key, $value); |
||
89 | } |
||
90 | |||
91 | if (($settingArgument = $input->getArgument('key')) !== null) { |
||
92 | $settingArgument = strtolower($settingArgument); |
||
93 | $this->infos = array_change_key_case($this->infos, CASE_LOWER); |
||
94 | if (!isset($this->infos[$settingArgument])) { |
||
95 | throw new InvalidArgumentException('Unknown key: ' . $settingArgument); |
||
96 | } |
||
97 | $output->writeln((string) $this->infos[$settingArgument]); |
||
98 | View Code Duplication | } else { |
|
99 | /* @var $tableHelper TableHelper */ |
||
100 | $tableHelper = $this->getHelper('table'); |
||
101 | $tableHelper |
||
102 | ->setHeaders(array('name', 'value')) |
||
103 | ->renderByFormat($output, $table, $input->getOption('format')); |
||
104 | } |
||
105 | } |
||
106 | |||
212 |