| Conditions | 2 |
| Paths | 2 |
| Total Lines | 86 |
| Code Lines | 64 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| 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 |
||
| 85 | protected function prepareAttributes() |
||
| 86 | { |
||
| 87 | |||
| 88 | // load the website ID for the given code |
||
| 89 | $websiteId = $this->getStoreWebsiteIdByCode($this->getValue(ColumnKeys::WEBSITE)); |
||
| 90 | |||
| 91 | // load the customer |
||
| 92 | $customer = $this->loadCustomerByEmailAndWebsiteId($this->getValue(ColumnKeys::EMAIL), $websiteId); |
||
| 93 | |||
| 94 | if (!$customer) { |
||
| 95 | $message = sprintf( |
||
| 96 | 'the imported address has no customer with email %s', |
||
| 97 | $this->getValue(ColumnKeys::EMAIL) |
||
| 98 | ); |
||
| 99 | $this->mergeStatus( |
||
| 100 | array( |
||
| 101 | RegistryKeys::NO_STRICT_VALIDATIONS => array( |
||
| 102 | basename($this->getFilename()) => array( |
||
| 103 | $this->getLineNumber() => array( |
||
| 104 | ColumnKeys::EMAIL => $message |
||
| 105 | ) |
||
| 106 | ) |
||
| 107 | ) |
||
| 108 | ) |
||
| 109 | ); |
||
| 110 | return []; |
||
| 111 | } |
||
| 112 | |||
| 113 | // initialize the customer values |
||
| 114 | $entityId = $this->getValue(ColumnKeys::ENTITY_ID); |
||
| 115 | $city = $this->getValue(ColumnKeys::CITY, ''); |
||
| 116 | $company = $this->getValue(ColumnKeys::COMPANY); |
||
| 117 | $countryId = $this->getValue(ColumnKeys::COUNTRY_ID, ''); |
||
| 118 | $fax = $this->getValue(ColumnKeys::FAX); |
||
| 119 | $firstname = $this->getValue(ColumnKeys::FIRSTNAME, ''); |
||
| 120 | $lastname = $this->getValue(ColumnKeys::LASTNAME, ''); |
||
| 121 | $middlename = $this->getValue(ColumnKeys::MIDDLENAME); |
||
| 122 | $postcode = $this->getValue(ColumnKeys::POSTCODE); |
||
| 123 | $prefix = $this->getValue(ColumnKeys::PREFIX); |
||
| 124 | $region = $this->getValue(ColumnKeys::REGION); |
||
| 125 | $regionId = $this->getValue(ColumnKeys::REGION_ID); |
||
| 126 | $street = $this->getValue(ColumnKeys::STREET, ''); |
||
| 127 | $suffix = $this->getValue(ColumnKeys::SUFFIX); |
||
| 128 | $telephone = $this->checkCustomerPhoneConfig($this->getValue(ColumnKeys::TELEPHONE, '')); |
||
| 129 | $vatId = $this->getValue(ColumnKeys::VAT_ID); |
||
| 130 | $vatIsValid = $this->getValue(ColumnKeys::VAT_IS_VALID); |
||
| 131 | $vatRequestId = $this->getValue(ColumnKeys::VAT_REQUEST_ID); |
||
| 132 | $vatRequestSuccess = $this->getValue(ColumnKeys::VAT_REQUEST_SUCCESS); |
||
| 133 | |||
| 134 | // load the customer's addtional attributes |
||
| 135 | $incrementId = $this->getValue(ColumnKeys::INCREMENT_ID); |
||
| 136 | $isActive = 1; |
||
| 137 | |||
| 138 | // prepare the date format for the created at/updated at dates |
||
| 139 | $createdAt = $this->getValue(ColumnKeys::CREATED_AT, date('Y-m-d H:i:s'), array($this, 'formatDate')); |
||
| 140 | $updatedAt = $this->getValue(ColumnKeys::UPDATED_AT, date('Y-m-d H:i:s'), array($this, 'formatDate')); |
||
| 141 | $vatRequestDate = $this->getValue(ColumnKeys::VAT_REQUEST_DATE, null, array($this, 'formatDate')); |
||
| 142 | |||
| 143 | // return the prepared customer |
||
| 144 | return $this->initializeEntity( |
||
| 145 | array( |
||
| 146 | MemberNames::ENTITY_ID => $entityId, |
||
| 147 | MemberNames::INCREMENT_ID => $incrementId, |
||
| 148 | MemberNames::PARENT_ID => $customer[MemberNames::ENTITY_ID], |
||
| 149 | MemberNames::CREATED_AT => $createdAt, |
||
| 150 | MemberNames::UPDATED_AT => $updatedAt, |
||
| 151 | MemberNames::IS_ACTIVE => $isActive, |
||
| 152 | MemberNames::CITY => $city, |
||
| 153 | MemberNames::COMPANY => $company, |
||
| 154 | MemberNames::COUNTRY_ID => $countryId, |
||
| 155 | MemberNames::FAX => $fax, |
||
| 156 | MemberNames::FIRSTNAME => $firstname, |
||
| 157 | MemberNames::LASTNAME => $lastname, |
||
| 158 | MemberNames::MIDDLENAME => $middlename, |
||
| 159 | MemberNames::POSTCODE => $postcode, |
||
| 160 | MemberNames::PREFIX => $prefix, |
||
| 161 | MemberNames::REGION => $region, |
||
| 162 | MemberNames::REGION_ID => $regionId, |
||
| 163 | MemberNames::STREET => $street, |
||
| 164 | MemberNames::SUFFIX => $suffix, |
||
| 165 | MemberNames::TELEPHONE => $telephone, |
||
| 166 | MemberNames::VAT_ID => $vatId, |
||
| 167 | MemberNames::VAT_IS_VALID => $vatIsValid, |
||
| 168 | MemberNames::VAT_REQUEST_DATE => $vatRequestDate, |
||
| 169 | MemberNames::VAT_REQUEST_ID => $vatRequestId, |
||
| 170 | MemberNames::VAT_REQUEST_SUCCESS => $vatRequestSuccess |
||
| 171 | ) |
||
| 295 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.