Conditions | 15 |
Paths | 4098 |
Total Lines | 50 |
Code Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 1 | 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 |
||
38 | protected function execute(InputInterface $input, OutputInterface $output) |
||
39 | { |
||
40 | $this->detectMagento($output); |
||
41 | if (!$this->initMagento()) { |
||
42 | return; |
||
43 | } |
||
44 | |||
45 | $entityType = $input->getArgument('entityType'); |
||
46 | $attributeCode = $input->getArgument('attributeCode'); |
||
47 | |||
48 | $attribute = $this->getAttribute($entityType, $attributeCode); |
||
49 | if (!$attribute) { |
||
50 | throw new InvalidArgumentException('Attribute was not found.'); |
||
51 | } |
||
52 | |||
53 | $table = array( |
||
54 | array('ID', $attribute->getId()), |
||
55 | array('Code', $attribute->getName()), |
||
56 | array('Attribute-Set-ID', $attribute->getAttributeSetId()), |
||
57 | array('Visible-On-Front', $attribute->getIsVisibleOnFront() ? 'yes' : 'no'), |
||
58 | array('Attribute-Model', $attribute->getAttributeModel() ? $attribute->getAttributeModel() : ''), |
||
59 | array('Backend-Model', $attribute->getBackendModel() ? $attribute->getBackendModel() : ''), |
||
60 | array('Backend-Table', $attribute->getBackendTable() ? $attribute->getBackendTable() : ''), |
||
61 | array('Backend-Type', $attribute->getBackendType() ? $attribute->getBackendType() : ''), |
||
62 | array('Source-Model', $attribute->getSourceModel() ? $attribute->getSourceModel() : ''), |
||
63 | array('Cache-ID-Tags', $attribute->getCacheIdTags() ? implode(',', $attribute->getCacheIdTags()) : ''), |
||
64 | array('Cache-Tags', $attribute->getCacheTags() ? implode(',', $attribute->getCacheTags()) : ''), |
||
65 | array('Default-Value', $attribute->getDefaultValue() ? $attribute->getDefaultValue() : ''), |
||
66 | array( |
||
67 | 'Flat-Columns', |
||
68 | $attribute->getFlatColumns() ? implode(',', array_keys($attribute->getFlatColumns())) : '', |
||
69 | ), |
||
70 | array('Flat-Indexes', $attribute->getFlatIndexes() ? implode(',', $attribute->getFlatIndexes()) : ''), |
||
71 | ); |
||
72 | |||
73 | if ($attribute->getFrontend()) { |
||
74 | $table[] = array('Frontend-Label', $attribute->getFrontend()->getLabel()); |
||
75 | $table[] = array('Frontend-Class', trim($attribute->getFrontend()->getClass())); |
||
76 | $table[] = array('Frontend-Input', trim($attribute->getFrontend()->getInputType())); |
||
77 | $table[] = array( |
||
78 | 'Frontend-Input-Renderer-Class', |
||
79 | trim($attribute->getFrontend()->getInputRendererClass()), |
||
80 | ); |
||
81 | } |
||
82 | |||
83 | $this |
||
84 | ->getHelper('table') |
||
85 | ->setHeaders(array('Type', 'Value')) |
||
86 | ->renderByFormat($output, $table, $input->getOption('format')); |
||
87 | } |
||
88 | |||
100 |