Conditions | 3 |
Paths | 3 |
Total Lines | 89 |
Code Lines | 66 |
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 |
||
95 | protected function prepareAttributes() |
||
96 | { |
||
97 | |||
98 | // load the website ID for the given code |
||
99 | $websiteId = $this->getStoreWebsiteIdByCode($this->getValue(ColumnKeys::WEBSITE)); |
||
100 | |||
101 | // load the customer |
||
102 | $customer = $this->loadCustomerByEmailAndWebsiteId($this->getValue(ColumnKeys::EMAIL), $websiteId); |
||
103 | |||
104 | if (!$customer) { |
||
105 | $message = sprintf( |
||
106 | 'the imported address has no customer with email %s', |
||
107 | $this->getValue(ColumnKeys::EMAIL) |
||
108 | ); |
||
109 | if ($this->subject->isStrictMode()) { |
||
110 | $this->mergeStatus( |
||
111 | array( |
||
112 | RegistryKeys::NO_STRICT_VALIDATIONS => array( |
||
113 | basename($this->getFilename()) => array( |
||
114 | $this->getLineNumber() => array( |
||
115 | $this->getValue(ColumnKeys::EMAIL) => $message |
||
116 | ) |
||
117 | ) |
||
118 | ) |
||
119 | ) |
||
120 | ); |
||
121 | } else { |
||
122 | throw new \Exception($message); |
||
123 | } |
||
124 | } |
||
125 | |||
126 | // initialize the customer values |
||
127 | $entityId = $this->getValue(ColumnKeys::ENTITY_ID); |
||
128 | $city = $this->getValue(ColumnKeys::CITY); |
||
129 | $company = $this->getValue(ColumnKeys::COMPANY); |
||
130 | $countryId = $this->getValue(ColumnKeys::COUNTRY_ID); |
||
131 | $fax = $this->getValue(ColumnKeys::FAX); |
||
132 | $firstname = $this->getValue(ColumnKeys::FIRSTNAME); |
||
133 | $lastname = $this->getValue(ColumnKeys::LASTNAME); |
||
134 | $middlename = $this->getValue(ColumnKeys::MIDDLENAME); |
||
135 | $postcode = $this->getValue(ColumnKeys::POSTCODE); |
||
136 | $prefix = $this->getValue(ColumnKeys::PREFIX); |
||
137 | $region = $this->getValue(ColumnKeys::REGION); |
||
138 | $regionId = $this->getValue(ColumnKeys::REGION_ID); |
||
139 | $street = $this->getValue(ColumnKeys::STREET); |
||
140 | $suffix = $this->getValue(ColumnKeys::SUFFIX); |
||
141 | $telephone = $this->checkConfigData($this->getValue(ColumnKeys::TELEPHONE)); |
||
142 | $vatId = $this->getValue(ColumnKeys::VAT_ID); |
||
143 | $vatIsValid = $this->getValue(ColumnKeys::VAT_IS_VALID); |
||
144 | $vatRequestId = $this->getValue(ColumnKeys::VAT_REQUEST_ID); |
||
145 | $vatRequestSuccess = $this->getValue(ColumnKeys::VAT_REQUEST_SUCCESS); |
||
146 | |||
147 | // load the customer's addtional attributes |
||
148 | $incrementId = $this->getValue(ColumnKeys::INCREMENT_ID); |
||
149 | $isActive = 1; |
||
150 | |||
151 | // prepare the date format for the created at/updated at dates |
||
152 | $createdAt = $this->getValue(ColumnKeys::CREATED_AT, date('Y-m-d H:i:s'), array($this, 'formatDate')); |
||
153 | $updatedAt = $this->getValue(ColumnKeys::UPDATED_AT, date('Y-m-d H:i:s'), array($this, 'formatDate')); |
||
154 | $vatRequestDate = $this->getValue(ColumnKeys::VAT_REQUEST_DATE, null, array($this, 'formatDate')); |
||
155 | |||
156 | // return the prepared customer |
||
157 | return $this->initializeEntity( |
||
158 | array( |
||
159 | MemberNames::ENTITY_ID => $entityId, |
||
160 | MemberNames::INCREMENT_ID => $incrementId, |
||
161 | MemberNames::PARENT_ID => $customer[MemberNames::ENTITY_ID], |
||
162 | MemberNames::CREATED_AT => $createdAt, |
||
163 | MemberNames::UPDATED_AT => $updatedAt, |
||
164 | MemberNames::IS_ACTIVE => $isActive, |
||
165 | MemberNames::CITY => $city, |
||
166 | MemberNames::COMPANY => $company, |
||
167 | MemberNames::COUNTRY_ID => $countryId, |
||
168 | MemberNames::FAX => $fax, |
||
169 | MemberNames::FIRSTNAME => $firstname, |
||
170 | MemberNames::LASTNAME => $lastname, |
||
171 | MemberNames::MIDDLENAME => $middlename, |
||
172 | MemberNames::POSTCODE => $postcode, |
||
173 | MemberNames::PREFIX => $prefix, |
||
174 | MemberNames::REGION => $region, |
||
175 | MemberNames::REGION_ID => $regionId, |
||
176 | MemberNames::STREET => $street, |
||
177 | MemberNames::SUFFIX => $suffix, |
||
178 | MemberNames::TELEPHONE => $telephone, |
||
179 | MemberNames::VAT_ID => $vatId, |
||
180 | MemberNames::VAT_IS_VALID => $vatIsValid, |
||
181 | MemberNames::VAT_REQUEST_DATE => $vatRequestDate, |
||
182 | MemberNames::VAT_REQUEST_ID => $vatRequestId, |
||
183 | MemberNames::VAT_REQUEST_SUCCESS => $vatRequestSuccess |
||
184 | ) |
||
307 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths