Conditions | 1 |
Paths | 1 |
Total Lines | 66 |
Code Lines | 56 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 |
||
107 | protected function prepareAttributes() |
||
108 | { |
||
109 | |||
110 | // initialize the customer values |
||
111 | $email = $this->getValue(ColumnKeys::EMAIL); |
||
112 | $groupId = $this->getValue(ColumnKeys::GROUP_ID); |
||
113 | $storeId = $this->getValue(ColumnKeys::STORE_ID); |
||
114 | $disableAutoGroupChange = $this->getValue(ColumnKeys::DISABLE_AUTO_GROUP_CHANGE); |
||
115 | $prefix = $this->getValue(ColumnKeys::PREFIX); |
||
116 | $firstname = $this->getValue(ColumnKeys::FIRSTNAME); |
||
117 | $middlename = $this->getValue(ColumnKeys::MIDDLENAME); |
||
118 | $lastname = $this->getValue(ColumnKeys::LASTNAME); |
||
119 | $suffix = $this->getValue(ColumnKeys::SUFFIX); |
||
120 | $passwordHash = $this->getValue(ColumnKeys::PASSWORD_HASH); |
||
121 | $rpToken = $this->getValue(ColumnKeys::RP_TOKEN); |
||
122 | $defaultShipping = $this->getValue(ColumnKeys::ADDRESS_DEFAULT_SHIPPING); |
||
123 | $defaultBilling = $this->getValue(ColumnKeys::ADDRESS_DEFAULT_BILLING); |
||
124 | $taxvat = $this->getValue(ColumnKeys::TAXVAT); |
||
125 | $confirmation = $this->getValue(ColumnKeys::CONFIRMATION); |
||
126 | $gender = $this->getGenderByValue($this->getValue(ColumnKeys::GENDER)); |
||
127 | |||
128 | // load the customer's addtional attributes |
||
129 | $createdIn = $this->getValue(ColumnKeys::CREATED_IN); |
||
130 | $incrementId = null; |
||
131 | $isActive = 1; |
||
132 | $failuresNum = 0; |
||
133 | $firstFailure = null; |
||
134 | $lockExpires = null; |
||
135 | |||
136 | // prepare the date format for the created at/updated at dates |
||
137 | $websiteId = $this->getStoreWebsiteIdByCode($this->getValue(ColumnKeys::WEBSITE)); |
||
138 | $dob = $this->getValue(ColumnKeys::DOB, date('Y-m-d H:i:s'), array($this, 'formatDate')); |
||
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 | $rpTokenCreatedAt = $this->getValue(ColumnKeys::RP_TOKEN_CREATED_AT, date('Y-m-d H:i:s'), array($this, 'formatDate')); |
||
142 | |||
143 | // return the prepared customer |
||
144 | return $this->initializeEntity( |
||
145 | array( |
||
146 | MemberNames::WEBSITE_ID => $websiteId, |
||
147 | MemberNames::EMAIL => $email, |
||
148 | MemberNames::GROUP_ID => $groupId, |
||
149 | MemberNames::INCREMENT_ID => $incrementId, |
||
150 | MemberNames::STORE_ID => $storeId, |
||
151 | MemberNames::CREATED_AT => $createdAt, |
||
152 | MemberNames::UPDATED_AT => $updatedAt, |
||
153 | MemberNames::IS_ACTIVE => $isActive, |
||
154 | MemberNames::DISABLE_AUTO_GROUP_CHANGE => $disableAutoGroupChange, |
||
155 | MemberNames::CREATED_IN => $createdIn, |
||
156 | MemberNames::PREFIX => $prefix, |
||
157 | MemberNames::FIRSTNAME => $firstname, |
||
158 | MemberNames::MIDDLENAME => $middlename, |
||
159 | MemberNames::LASTNAME => $lastname, |
||
160 | MemberNames::SUFFIX => $suffix, |
||
161 | MemberNames::DOB => $dob, |
||
162 | MemberNames::PASSWORD_HASH => $passwordHash, |
||
163 | MemberNames::RP_TOKEN => $rpToken, |
||
164 | MemberNames::RP_TOKEN_CREATED_AT => $rpTokenCreatedAt, |
||
165 | MemberNames::DEFAULT_BILLING => $defaultBilling, |
||
166 | MemberNames::DEFAULT_SHIPPING => $defaultShipping, |
||
167 | MemberNames::TAXVAT => $taxvat, |
||
168 | MemberNames::CONFIRMATION => $confirmation, |
||
169 | MemberNames::GENDER => $gender, |
||
170 | MemberNames::FAILURES_NUM => $failuresNum, |
||
171 | MemberNames::FIRST_FAILURE => $firstFailure, |
||
172 | MemberNames::LOCK_EXPIRES => $lockExpires |
||
173 | ) |
||
279 |