Conditions | 3 |
Paths | 3 |
Total Lines | 56 |
Code Lines | 52 |
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 |
||
133 | private function setStandardizedFeedbackArray(array $arrayData): array |
||
134 | { |
||
135 | $arrayToReturn = [ |
||
136 | 'Response_Date' => '', |
||
137 | 'Response_Index' => $arrayData['Response_Index'], |
||
138 | 'Loading_Index' => '', |
||
139 | 'Size' => '', |
||
140 | 'Document_No' => '', |
||
141 | 'Issue_Date' => '', |
||
142 | 'Issue_YearMonth' => '', |
||
143 | 'Amount_wo_VAT' => '', |
||
144 | 'Amount_TOTAL' => '', |
||
145 | 'Amount_VAT' => '', |
||
146 | 'Supplier_CUI' => '', |
||
147 | 'Supplier_Name' => '', |
||
148 | 'Customer_CUI' => '', |
||
149 | 'Customer_Name' => '', |
||
150 | 'No_of_Lines' => '', |
||
151 | 'Error' => '', |
||
152 | 'Days_Between' => '', |
||
153 | ]; |
||
154 | if ($arrayData['Size'] > 1000) { |
||
155 | $arrayAttr = $this->getDocumentDetails($arrayData); |
||
156 | $arrayToReturn['Loading_Index'] = substr($arrayData['Matches'][0][0], 0, -4); |
||
157 | $arrayToReturn['Size'] = $arrayData['Size']; |
||
158 | $arrayToReturn['Document_No'] = $arrayAttr['ID']; |
||
159 | $arrayToReturn['Issue_Date'] = $arrayAttr['IssueDate']; |
||
160 | $arrayToReturn['Issue_YearMonth'] = (new \IntlDateFormatter( |
||
161 | $_GET['language_COUNTRY'], |
||
162 | \IntlDateFormatter::FULL, |
||
163 | \IntlDateFormatter::FULL, |
||
164 | $this->translation->find(null, 'i18n_TimeZone')->getTranslation(), |
||
165 | \IntlDateFormatter::GREGORIAN, |
||
166 | 'r-MM__MMMM' |
||
167 | ))->format(new \DateTime($arrayAttr['IssueDate'])); |
||
168 | $arrayToReturn['Response_Date'] = $arrayData['FileDate']; |
||
169 | $arrayToReturn['Amount_wo_VAT'] = $arrayAttr['wo_VAT']; |
||
170 | $arrayToReturn['Amount_TOTAL'] = $arrayAttr['TOTAL']; |
||
171 | $arrayToReturn['Amount_VAT'] = round(($arrayAttr['TOTAL'] - $arrayAttr['wo_VAT']), 2); |
||
172 | $arrayToReturn['Supplier_CUI'] = $this->setDataSupplierOrCustomer($arrayAttr['Supplier']); |
||
173 | $arrayToReturn['Supplier_Name'] = $arrayAttr['Supplier']['PartyLegalEntity']['RegistrationName']; |
||
174 | $arrayToReturn['Customer_CUI'] = $this->setDataSupplierOrCustomer($arrayAttr['Customer']); |
||
175 | $arrayToReturn['Customer_Name'] = $arrayAttr['Customer']['PartyLegalEntity']['RegistrationName']; |
||
176 | $arrayToReturn['No_of_Lines'] = $arrayAttr['No_of_Lines']; |
||
177 | $arrayToReturn['Days_Between'] = $this->setDaysElapsed($arrayAttr['IssueDate'], $arrayData['FileDate']); |
||
178 | } elseif ($arrayData['Size'] > 0) { |
||
179 | $objErrors = new \SimpleXMLElement($arrayData['strInvoiceContent']); |
||
180 | $arrayToReturn['Loading_Index'] = $objErrors->attributes()->Index_incarcare->__toString(); |
||
181 | $arrayToReturn['Size'] = $arrayData['Size']; |
||
182 | $arrayToReturn['Response_Date'] = $arrayData['FileDate']; |
||
183 | $arrayToReturn['Supplier_CUI'] = 'RO' . $objErrors->attributes()->Cif_emitent->__toString(); |
||
184 | $arrayToReturn['Supplier_Name'] = '??????????'; |
||
185 | $arrayToReturn['Error'] = '<div style="max-width:200px;font-size:0.8rem;">' |
||
186 | . $objErrors->Error->attributes()->errorMessage->__toString() . '</div>'; |
||
187 | } |
||
188 | return $arrayToReturn; |
||
189 | } |
||
191 |