| Conditions | 6 |
| Paths | 2 |
| Total Lines | 77 |
| Code Lines | 61 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 72 | protected function process() |
||
| 73 | { |
||
| 74 | // load the email with the column keys of the customer-address CSV file |
||
| 75 | $email = $this->getValue(\TechDivision\Import\Customer\Utils\ColumnKeys::EMAIL); |
||
| 76 | |||
| 77 | $firstName = $this->getValue(ColumnKeys::ADDRESS_FIRSTNAME, ''); |
||
| 78 | $lastName = $this->getValue(ColumnKeys::ADDRESS_LASTNAME, ''); |
||
| 79 | $addressStreet = $this->getValue(ColumnKeys::ADDRESS_STREET, ''); |
||
| 80 | $addressCity = $this->getValue(ColumnKeys::ADDRESS_CITY, ''); |
||
| 81 | $countryId = $this->getValue(ColumnKeys::ADDRESS_COUNTRY_ID, ''); |
||
| 82 | |||
| 83 | if (empty($addressCity) |
||
| 84 | && empty($addressStreet) |
||
| 85 | && empty($firstName) |
||
| 86 | && empty($lastName) |
||
| 87 | && empty($countryId) |
||
| 88 | ) { |
||
| 89 | $this->getSystemLogger()->warning( |
||
| 90 | sprintf( |
||
| 91 | 'The customer address was not initialized, no address data specified for the email "%s"', |
||
| 92 | |||
| 93 | ) |
||
| 94 | ); |
||
| 95 | return; |
||
| 96 | } |
||
| 97 | // initialize the array for the links |
||
| 98 | $artefacts = array(); |
||
| 99 | |||
| 100 | $artefacts[] = $this->newArtefact( |
||
| 101 | array( |
||
| 102 | ColumnKeys::ENTITY_ID => $this->getValue(ColumnKeys::ENTITY_ID), |
||
| 103 | ColumnKeys::INCREMENT_ID => $this->getValue(ColumnKeys::ADDRESS_INCREMENT_ID), |
||
| 104 | ColumnKeys::EMAIL => $email, |
||
| 105 | ColumnKeys::WEBSITE => $this->getValue(ColumnKeys::WEBSITE), |
||
| 106 | ColumnKeys::CITY => $addressCity, |
||
| 107 | ColumnKeys::COMPANY => $this->getValue(ColumnKeys::ADDRESS_COMPANY), |
||
| 108 | ColumnKeys::COUNTRY_ID => $countryId, |
||
| 109 | ColumnKeys::FAX => $this->getValue(ColumnKeys::ADDRESS_FAX), |
||
| 110 | ColumnKeys::FIRSTNAME => $firstName, |
||
| 111 | ColumnKeys::LASTNAME => $lastName, |
||
| 112 | ColumnKeys::MIDDLENAME => $this->getValue(ColumnKeys::ADDRESS_MIDDLENAME), |
||
| 113 | ColumnKeys::POSTCODE => $this->getValue(ColumnKeys::ADDRESS_POSTCODE), |
||
| 114 | ColumnKeys::PREFIX => $this->getValue(ColumnKeys::ADDRESS_PREFIX), |
||
| 115 | ColumnKeys::REGION => $this->getValue(ColumnKeys::ADDRESS_REGION), |
||
| 116 | ColumnKeys::STREET => $addressStreet, |
||
| 117 | ColumnKeys::SUFFIX => $this->getValue(ColumnKeys::ADDRESS_SUFFIX), |
||
| 118 | ColumnKeys::TELEPHONE => $this->getValue(ColumnKeys::ADDRESS_TELEPHONE), |
||
| 119 | ColumnKeys::VAT_ID => $this->getValue(ColumnKeys::ADDRESS_VAT_ID), |
||
| 120 | ColumnKeys::ADDRESS_DEFAULT_BILLING => $this->getValue(ColumnKeys::ADDRESS_DEFAULT_BILLING), |
||
| 121 | ColumnKeys::ADDRESS_DEFAULT_SHIPPING => $this->getValue(ColumnKeys::ADDRESS_DEFAULT_SHIPPING) |
||
| 122 | ), |
||
| 123 | array( |
||
| 124 | ColumnKeys::ENTITY_ID => ColumnKeys::ENTITY_ID, |
||
| 125 | ColumnKeys::INCREMENT_ID => ColumnKeys::INCREMENT_ID, |
||
| 126 | ColumnKeys::WEBSITE => ColumnKeys::WEBSITE, |
||
| 127 | ColumnKeys::EMAIL => ColumnKeys::EMAIL, |
||
| 128 | ColumnKeys::CITY => ColumnKeys::ADDRESS_CITY, |
||
| 129 | ColumnKeys::COMPANY => ColumnKeys::ADDRESS_COMPANY, |
||
| 130 | ColumnKeys::COUNTRY_ID => ColumnKeys::ADDRESS_COUNTRY_ID, |
||
| 131 | ColumnKeys::FAX => ColumnKeys::ADDRESS_FAX, |
||
| 132 | ColumnKeys::FIRSTNAME => ColumnKeys::ADDRESS_FIRSTNAME, |
||
| 133 | ColumnKeys::LASTNAME => ColumnKeys::ADDRESS_LASTNAME, |
||
| 134 | ColumnKeys::MIDDLENAME => ColumnKeys::ADDRESS_MIDDLENAME, |
||
| 135 | ColumnKeys::POSTCODE => ColumnKeys::ADDRESS_POSTCODE, |
||
| 136 | ColumnKeys::PREFIX => ColumnKeys::ADDRESS_PREFIX, |
||
| 137 | ColumnKeys::REGION => ColumnKeys::ADDRESS_REGION, |
||
| 138 | ColumnKeys::STREET => ColumnKeys::ADDRESS_STREET, |
||
| 139 | ColumnKeys::SUFFIX => ColumnKeys::ADDRESS_SUFFIX, |
||
| 140 | ColumnKeys::TELEPHONE => ColumnKeys::ADDRESS_TELEPHONE, |
||
| 141 | ColumnKeys::VAT_ID => ColumnKeys::ADDRESS_VAT_ID, |
||
| 142 | ColumnKeys::ADDRESS_DEFAULT_BILLING => ColumnKeys::ADDRESS_DEFAULT_BILLING, |
||
| 143 | ColumnKeys::ADDRESS_DEFAULT_SHIPPING => ColumnKeys::ADDRESS_DEFAULT_SHIPPING |
||
| 144 | ) |
||
| 145 | ); |
||
| 146 | |||
| 147 | // append the links to the subject |
||
| 148 | $this->addArtefacts($artefacts); |
||
| 149 | } |
||
| 178 |