| Conditions | 1 |
| Paths | 1 |
| Total Lines | 61 |
| Code Lines | 51 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 87 | protected function prepareAttributes() |
||
| 88 | { |
||
| 89 | |||
| 90 | // load the recently created EAV attribute ID |
||
| 91 | $attributeId = $this->getLastAttributeId(); |
||
| 92 | |||
| 93 | // load the data from the row |
||
| 94 | $frontendInputRenderer = $this->getValue(ColumnKeys::FRONTEND_INPUT_RENDERER); |
||
| 95 | $isGlobal = $this->getValue(ColumnKeys::IS_GLOBAL, 1); |
||
| 96 | $isVisible = $this->getValue(ColumnKeys::IS_VISIBLE, 1); |
||
| 97 | $isSearchable = $this->getValue(ColumnKeys::IS_SEARCHABLE, 0); |
||
| 98 | $isFilterable = $this->getValue(ColumnKeys::IS_FILTERABLE, 0); |
||
| 99 | $isComparable = $this->getValue(ColumnKeys::IS_COMPARABLE, 0); |
||
| 100 | $isVisibleOnFront = $this->getValue(ColumnKeys::IS_VISIBLE_ON_FRONT, 0); |
||
| 101 | $isHtmlAllowedOnFront = $this->getValue(ColumnKeys::IS_HTML_ALLOWED_ON_FRONT, 0); |
||
| 102 | $isUsedForPriceRules = $this->getValue(ColumnKeys::IS_USED_FOR_PRICE_RULES, 0); |
||
| 103 | $isFilterableInSearch = $this->getValue(ColumnKeys::IS_FILTERABLE_IN_SEARCH, 0); |
||
| 104 | $usedInProductListing = $this->getValue(ColumnKeys::USED_IN_PRODUCT_LISTING, 0); |
||
| 105 | $usedForSortBy = $this->getValue(ColumnKeys::USED_FOR_SORT_BY, 0); |
||
| 106 | $applyTo = $this->getValue(ColumnKeys::APPLY_TO); |
||
| 107 | $isVisibleInAdvancedSearch = $this->getValue(ColumnKeys::IS_VISIBLE_IN_ADVANCED_SEARCH, 0); |
||
| 108 | $position = $this->getValue(ColumnKeys::POSITION, 0); |
||
| 109 | $isWysiwygEnabled = $this->getValue(ColumnKeys::IS_WYSIWYG_ENABLED, 0); |
||
| 110 | $isUsedForPromoRules = $this->getValue(ColumnKeys::IS_USED_FOR_PROMO_RULES, 0); |
||
| 111 | $isRequiredInAdminStore = $this->getValue(ColumnKeys::IS_REQUIRED_IN_ADMIN_STORE, 0); |
||
| 112 | $isUsedInGrid = $this->getValue(ColumnKeys::IS_USED_IN_GRID, 0); |
||
| 113 | $isVisibleInGrid = $this->getValue(ColumnKeys::IS_VISIBLE_IN_GRID, 0); |
||
| 114 | $isFilterableInGrid = $this->getValue(ColumnKeys::IS_FILTERABLE_IN_GRID, 0); |
||
| 115 | $searchWeight = $this->getValue(ColumnKeys::SEARCH_WEIGHT, 1); |
||
| 116 | $additionalData = $this->getValue(ColumnKeys::ADDITIONAL_DATA); |
||
| 117 | |||
| 118 | // return the prepared product |
||
| 119 | return $this->initializeEntity( |
||
| 120 | array( |
||
| 121 | MemberNames::ATTRIBUTE_ID => $attributeId, |
||
| 122 | MemberNames::FRONTEND_INPUT_RENDERER => $frontendInputRenderer, |
||
| 123 | MemberNames::IS_GLOBAL => $isGlobal, |
||
| 124 | MemberNames::IS_VISIBLE => $isVisible, |
||
| 125 | MemberNames::IS_SEARCHABLE => $isSearchable, |
||
| 126 | MemberNames::IS_FILTERABLE => $isFilterable, |
||
| 127 | MemberNames::IS_COMPARABLE => $isComparable, |
||
| 128 | MemberNames::IS_VISIBLE_ON_FRONT => $isVisibleOnFront, |
||
| 129 | MemberNames::IS_HTML_ALLOWED_ON_FRONT => $isHtmlAllowedOnFront, |
||
| 130 | MemberNames::IS_USED_FOR_PRICE_RULES => $isUsedForPriceRules, |
||
| 131 | MemberNames::IS_FILTERABLE_IN_SEARCH => $isFilterableInSearch, |
||
| 132 | MemberNames::USED_IN_PRODUCT_LISTING => $usedInProductListing, |
||
| 133 | MemberNames::USED_FOR_SORT_BY => $usedForSortBy, |
||
| 134 | MemberNames::APPLY_TO => $applyTo, |
||
| 135 | MemberNames::IS_VISIBLE_IN_ADVANCED_SEARCH => $isVisibleInAdvancedSearch, |
||
| 136 | MemberNames::POSITION => $position, |
||
| 137 | MemberNames::IS_WYSIWYG_ENABLED => $isWysiwygEnabled, |
||
| 138 | MemberNames::IS_USED_FOR_PROMO_RULES => $isUsedForPromoRules, |
||
| 139 | MemberNames::IS_REQUIRED_IN_ADMIN_STORE => $isRequiredInAdminStore, |
||
| 140 | MemberNames::IS_USED_IN_GRID => $isUsedInGrid, |
||
| 141 | MemberNames::IS_VISIBLE_IN_GRID => $isVisibleInGrid, |
||
| 142 | MemberNames::IS_FILTERABLE_IN_GRID => $isFilterableInGrid, |
||
| 143 | MemberNames::SEARCH_WEIGHT => $searchWeight, |
||
| 144 | MemberNames::ADDITIONAL_DATA => $additionalData |
||
| 145 | ) |
||
| 146 | ); |
||
| 147 | } |
||
| 148 | |||
| 183 |