| Conditions | 5 |
| Paths | 12 |
| Total Lines | 58 |
| Code Lines | 50 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 82 | private static function getDocumentData(DataMap $inv) { |
||
| 83 | $currency = Catalogo::getCurrencyPlural($inv->getCurrencyCode()); |
||
| 84 | $payableAmount = $inv->getPayableAmount(); |
||
| 85 | $payableInWords = Operations::getAmountInWords($payableAmount, $currency); |
||
| 86 | // has dueDate = |
||
| 87 | $dueDate = $inv->getDueDate(); |
||
| 88 | $formOfPayment = $inv->getFormOfPayment(); |
||
| 89 | $formOfPaymentSrt = ""; |
||
| 90 | if($formOfPayment == Catalogo::FAC_FORM_OF_PAYMENT_CONTADO) { |
||
| 91 | $formOfPaymentSrt = "CONTADO"; |
||
| 92 | }elseif($formOfPayment == Catalogo::FAC_FORM_OF_PAYMENT_CREDITO) { |
||
| 93 | $formOfPaymentSrt = "CRÉDITO"; |
||
| 94 | } |
||
| 95 | $data = [ |
||
| 96 | 'companyName' => Company::getCompanyName(), |
||
| 97 | 'companyRuc' => Company::getRUC(), |
||
| 98 | 'companyAddress' => Company::getAddress(), |
||
| 99 | 'companyCity' => Company::getCity(), |
||
| 100 | 'edocHeaderContent' => Company::getEdocHeaderContent(), |
||
| 101 | 'edocFooterContent' => Company::getEdocFooterContent(), |
||
| 102 | 'documentSeries' => $inv->getDocumentSeries(), |
||
| 103 | 'documentNumber' => $inv->getDocumentNumber(), |
||
| 104 | 'officialDocumentName' => $inv->getOfficialDocumentName(), |
||
| 105 | 'currency' => $currency, |
||
| 106 | 'customerRegName' => $inv->getCustomerRegName(), |
||
| 107 | 'customerDocNumber' => $inv->getCustomerDocNumber(), |
||
| 108 | 'customerAddress' => $inv->getCustomerAddress(), |
||
| 109 | 'issueDate' => $inv->getIssueDate()->format('d-m-Y'), |
||
| 110 | 'dueDate' => $dueDate ? $dueDate->format('d-m-Y') : '', |
||
| 111 | 'igvPercent' => SunatVars::IGV_PERCENT, |
||
| 112 | 'logo' => LogoMgr::getLogoString(), |
||
| 113 | 'qr' => QrGenerator::getQrString($inv), // QR Code |
||
| 114 | 'taxableOperations' => $inv->getTotalTaxableOperations(), // Total operaciones gravadas |
||
| 115 | 'freeOperations' => $inv->getTotalFreeOperations(), // Total operaciones gratuitas |
||
| 116 | 'unaffectedOperations' => $inv->getTotalUnaffectedOperations(), // Total operaciones inafectas |
||
| 117 | 'exemptedOperations' => $inv->getTotalExemptedOperations(), // Total operaciones exoneradas |
||
| 118 | 'totalAllowances' => $inv->getTotalAllowances(), // Total operaciones exoneradas |
||
| 119 | 'igvAmount' => $inv->getIGV(), // IGV |
||
| 120 | 'payableAmount' => $payableAmount, // Total a pagar |
||
| 121 | 'formOfPaymentStr' => $formOfPaymentSrt, // Forma de pago |
||
| 122 | 'pendingAmount' => $inv->getPendingAmount(), // Forma de pago |
||
| 123 | 'payableInWords' => $payableInWords, // Monto en palabras |
||
| 124 | 'items' => self::getDocumentDataItems($inv), // Items |
||
| 125 | 'installments' => self::getDocumentInstallments($inv), // Cuotas |
||
| 126 | ]; |
||
| 127 | // For credit and debit notes |
||
| 128 | if (in_array($inv->getDocumentType(), [Catalogo::DOCTYPE_NOTA_CREDITO, Catalogo::DOCTYPE_NOTA_DEBITO])) { |
||
| 129 | $noteData = [ |
||
| 130 | 'noteType' => $inv->getNoteType(), |
||
| 131 | 'discrepancyResponseReason' => $inv->getDiscrepancyResponseReason(), |
||
| 132 | 'affectedDocumentId' => $inv->getNoteAffectedDocId(), |
||
| 133 | 'affectedDocumentOficialName' => Catalogo::getOfficialDocumentName($inv->getNoteAffectedDocType()), |
||
| 134 | 'note' => $inv->getNoteDescription() |
||
| 135 | ]; |
||
| 136 | return array_merge($data, $noteData); |
||
| 137 | } |
||
| 138 | |||
| 139 | return $data; |
||
| 140 | } |
||
| 184 |