Conditions | 4 |
Paths | 4 |
Total Lines | 62 |
Code Lines | 57 |
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 |
||
175 | private function setStandardizedFeedbackArray(array $arrayData): array |
||
176 | { |
||
177 | $arrayToReturn = [ |
||
178 | 'Response_Date' => '', |
||
179 | 'Response_Index' => $arrayData['Response_Index'], |
||
180 | 'Loading_Index' => '', |
||
181 | 'Size' => '', |
||
182 | 'Document_No' => '', |
||
183 | 'Issue_Date' => '', |
||
184 | 'Issue_YearMonth' => '', |
||
185 | 'Amount_wo_VAT' => '', |
||
186 | 'Amount_TOTAL' => '', |
||
187 | 'Amount_VAT' => '', |
||
188 | 'Supplier_CUI' => '', |
||
189 | 'Supplier_Name' => '', |
||
190 | 'Customer_CUI' => '', |
||
191 | 'Customer_Name' => '', |
||
192 | 'No_of_Lines' => '', |
||
193 | 'Error' => '', |
||
194 | 'Days_Between' => '', |
||
195 | ]; |
||
196 | $strErrorTag = '<div style="max-width:200px;font-size:0.8rem;">%s</div>'; |
||
197 | if (array_key_exists('Error', $arrayData)) { |
||
198 | $arrayToReturn['Error'] = sprintf($strErrorTag, $arrayData['Error']); |
||
199 | $arrayToReturn['Size'] = 0; |
||
200 | } elseif ($arrayData['Size'] > 1000) { |
||
201 | $strTimeZone = $this->translation->find(null, 'i18n_TimeZone')->getTranslation(); |
||
202 | $strFormatter = new \IntlDateFormatter( |
||
203 | $_GET['language_COUNTRY'], |
||
204 | \IntlDateFormatter::FULL, |
||
205 | \IntlDateFormatter::FULL, |
||
206 | $strTimeZone, |
||
207 | \IntlDateFormatter::GREGORIAN, |
||
208 | 'r-MM__MMMM' |
||
209 | ); |
||
210 | $arrayAttr = $this->getDocumentDetails($arrayData); |
||
211 | $arrayToReturn['Loading_Index'] = substr($arrayData['Matches'][0][0], 0, -4); |
||
212 | $arrayToReturn['Size'] = $arrayData['Size']; |
||
213 | $arrayToReturn['Document_No'] = $arrayAttr['ID']; |
||
214 | $arrayToReturn['Issue_Date'] = $arrayAttr['IssueDate']; |
||
215 | $arrayToReturn['Issue_YearMonth'] = $strFormatter->format(new \DateTime($arrayAttr['IssueDate'])); |
||
216 | $arrayToReturn['Response_Date'] = $arrayData['FileDate']; |
||
217 | $arrayToReturn['Amount_wo_VAT'] = $arrayAttr['wo_VAT']; |
||
218 | $arrayToReturn['Amount_TOTAL'] = $arrayAttr['TOTAL']; |
||
219 | $arrayToReturn['Amount_VAT'] = round(($arrayAttr['TOTAL'] - $arrayAttr['wo_VAT']), 2); |
||
220 | $arrayToReturn['Supplier_CUI'] = $this->setDataSupplierOrCustomer($arrayAttr['Supplier']); |
||
221 | $arrayToReturn['Supplier_Name'] = $arrayAttr['Supplier']['PartyLegalEntity']['RegistrationName']; |
||
222 | $arrayToReturn['Customer_CUI'] = $this->setDataSupplierOrCustomer($arrayAttr['Customer']); |
||
223 | $arrayToReturn['Customer_Name'] = $arrayAttr['Customer']['PartyLegalEntity']['RegistrationName']; |
||
224 | $arrayToReturn['No_of_Lines'] = $arrayAttr['No_of_Lines']; |
||
225 | $arrayToReturn['Days_Between'] = $this->setDaysElapsed($arrayAttr['IssueDate'], $arrayData['FileDate']); |
||
226 | } elseif ($arrayData['Size'] > 0) { |
||
227 | $objErrors = new \SimpleXMLElement($arrayData['strInvoiceContent']); |
||
228 | $arrayToReturn['Loading_Index'] = $objErrors->attributes()->Index_incarcare->__toString(); |
||
229 | $arrayToReturn['Size'] = $arrayData['Size']; |
||
230 | $arrayToReturn['Response_Date'] = $arrayData['FileDate']; |
||
231 | $arrayToReturn['Supplier_CUI'] = 'RO' . $objErrors->attributes()->Cif_emitent->__toString(); |
||
232 | $arrayToReturn['Supplier_Name'] = '??????????'; |
||
233 | $arrayToReturn['Error'] = sprintf($strErrorTag, $objErrors |
||
234 | ->Error->attributes()->errorMessage->__toString()); |
||
235 | } |
||
236 | return $arrayToReturn; |
||
237 | } |
||
239 |