Conditions | 1 |
Paths | 1 |
Total Lines | 67 |
Code Lines | 53 |
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 |
||
86 | protected function prepareAttributes() |
||
87 | { |
||
88 | |||
89 | // load the website ID for the given code |
||
90 | $websiteId = $this->getStoreWebsiteIdByCode($this->getValue(ColumnKeys::WEBSITE)); |
||
91 | |||
92 | // load the customer |
||
93 | $customer = $this->loadCustomerByEmailAndWebsiteId($this->getValue(ColumnKeys::EMAIL), $websiteId); |
||
94 | |||
95 | // initialize the customer values |
||
96 | $entityId = $this->getValue(ColumnKeys::ENTITY_ID); |
||
97 | $city = $this->getValue(ColumnKeys::CITY); |
||
98 | $company = $this->getValue(ColumnKeys::COMPANY); |
||
99 | $countryId = $this->getValue(ColumnKeys::COUNTRY_ID); |
||
100 | $fax = $this->getValue(ColumnKeys::FAX); |
||
101 | $firstname = $this->getValue(ColumnKeys::FIRSTNAME); |
||
102 | $lastname = $this->getValue(ColumnKeys::LASTNAME); |
||
103 | $middlename = $this->getValue(ColumnKeys::MIDDLENAME); |
||
104 | $postcode = $this->getValue(ColumnKeys::POSTCODE); |
||
105 | $prefix = $this->getValue(ColumnKeys::PREFIX); |
||
106 | $region = $this->getValue(ColumnKeys::REGION); |
||
107 | $regionId = $this->getValue(ColumnKeys::REGION_ID); |
||
108 | $street = $this->getValue(ColumnKeys::STREET); |
||
109 | $suffix = $this->getValue(ColumnKeys::SUFFIX); |
||
110 | $telephone = $this->getValue(ColumnKeys::TELEPHONE); |
||
111 | $vatId = $this->getValue(ColumnKeys::VAT_ID); |
||
112 | $vatIsValid = $this->getValue(ColumnKeys::VAT_IS_VALID); |
||
113 | $vatRequestId = $this->getValue(ColumnKeys::VAT_REQUEST_ID); |
||
114 | $vatRequestSuccess = $this->getValue(ColumnKeys::VAT_REQUEST_SUCCESS); |
||
115 | |||
116 | // load the customer's addtional attributes |
||
117 | $incrementId = null; |
||
118 | $isActive = 1; |
||
119 | |||
120 | // prepare the date format for the created at/updated at dates |
||
121 | $createdAt = $this->getValue(ColumnKeys::CREATED_AT, date('Y-m-d H:i:s'), array($this, 'formatDate')); |
||
122 | $updatedAt = $this->getValue(ColumnKeys::UPDATED_AT, date('Y-m-d H:i:s'), array($this, 'formatDate')); |
||
123 | $vatRequestDate = $this->getValue(ColumnKeys::VAT_REQUEST_DATE, date('Y-m-d H:i:s'), array($this, 'formatDate')); |
||
124 | |||
125 | // return the prepared customer |
||
126 | return $this->initializeEntity( |
||
127 | array( |
||
128 | MemberNames::ENTITY_ID => $entityId, |
||
129 | MemberNames::INCREMENT_ID => $incrementId, |
||
130 | MemberNames::PARENT_ID => $customer[MemberNames::ENTITY_ID], |
||
131 | MemberNames::CREATED_AT => $createdAt, |
||
132 | MemberNames::UPDATED_AT => $updatedAt, |
||
133 | MemberNames::IS_ACTIVE => $isActive, |
||
134 | MemberNames::CITY => $city, |
||
135 | MemberNames::COMPANY => $company, |
||
136 | MemberNames::COUNTRY_ID => $countryId, |
||
137 | MemberNames::FAX => $fax, |
||
138 | MemberNames::FIRSTNAME => $firstname, |
||
139 | MemberNames::LASTNAME => $lastname, |
||
140 | MemberNames::MIDDLENAME => $middlename, |
||
141 | MemberNames::POSTCODE => $postcode, |
||
142 | MemberNames::PREFIX => $prefix, |
||
143 | MemberNames::REGION => $region, |
||
144 | MemberNames::REGION_ID => $regionId, |
||
145 | MemberNames::STREET => $street, |
||
146 | MemberNames::SUFFIX => $suffix, |
||
147 | MemberNames::TELEPHONE => $telephone, |
||
148 | MemberNames::VAT_ID => $vatId, |
||
149 | MemberNames::VAT_IS_VALID => $vatIsValid, |
||
150 | MemberNames::VAT_REQUEST_DATE => $vatRequestDate, |
||
151 | MemberNames::VAT_REQUEST_ID => $vatRequestId, |
||
152 | MemberNames::VAT_REQUEST_SUCCESS => $vatRequestSuccess |
||
153 | ) |
||
241 |