| Conditions | 7 |
| Paths | 64 |
| Total Lines | 103 |
| Code Lines | 64 |
| 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 |
||
| 31 | public function xmlSerialize(Writer $writer) { |
||
| 32 | $companyRUC = Company::getRUC(); |
||
| 33 | $companyName = Company::getCompanyName(); |
||
| 34 | // SchemaNS::EXT . 'UBLExtensions' |
||
| 35 | $UBLExtensions = TemplateMgr::getTpl('UBLExtensions.xml'); |
||
| 36 | $Signature = TemplateMgr::getTpl('Signature.xml', [ |
||
| 37 | 'RUC' => $companyRUC, |
||
| 38 | 'companyName' => $companyName |
||
| 39 | ]); |
||
| 40 | $this->writeLineJump($writer); |
||
| 41 | $writer->writeRaw($UBLExtensions); |
||
| 42 | |||
| 43 | $writer->write([ |
||
| 44 | SchemaNS::CBC . 'UBLVersionID' => self::UBL_VERSION_ID, |
||
| 45 | SchemaNS::CBC . 'CustomizationID' => self::CUSTUMIZATION_ID, |
||
| 46 | [ |
||
| 47 | 'name' => SchemaNS::CBC . 'ProfileID', |
||
| 48 | 'value' => $this->ProfileID, |
||
| 49 | 'attributes' => [ |
||
| 50 | 'schemeName' => 'SUNAT:Identificador de Tipo de Operación', |
||
| 51 | 'schemeAgencyName' => 'PE:SUNAT', |
||
| 52 | 'schemeURI' => 'urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo17' |
||
| 53 | ] |
||
| 54 | ], |
||
| 55 | SchemaNS::CBC . 'ID' => $this->ID, |
||
| 56 | SchemaNS::CBC . 'IssueDate' => $this->IssueDate->format('Y-m-d'), |
||
| 57 | SchemaNS::CBC . 'IssueTime' => $this->IssueDate->format('H:i:s') |
||
| 58 | ]); |
||
| 59 | if ($this->DueDate) { |
||
| 60 | $writer->write([ |
||
| 61 | SchemaNS::CBC . 'DueDate' => $this->DueDate->format('Y-m-d') |
||
| 62 | ]); |
||
| 63 | } |
||
| 64 | $writer->write([ |
||
| 65 | [ |
||
| 66 | 'name' => SchemaNS::CBC . 'InvoiceTypeCode', |
||
| 67 | 'value' => $this->InvoiceTypeCode, |
||
| 68 | 'attributes' => [ |
||
| 69 | 'listAgencyName' => 'PE:SUNAT', |
||
| 70 | 'listID' => $this->ProfileID, |
||
| 71 | 'listName' => 'Tipo de Documento', |
||
| 72 | 'listSchemeURI' => 'urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo51', |
||
| 73 | 'listURI' => 'urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo01', |
||
| 74 | 'name' => 'Tipo de Operacion' |
||
| 75 | ] |
||
| 76 | ] |
||
| 77 | ]); |
||
| 78 | |||
| 79 | // Write notes |
||
| 80 | foreach ($this->Notes as $InvoiceLine) { |
||
| 81 | $writer->write($InvoiceLine); |
||
| 82 | } |
||
| 83 | |||
| 84 | $writer->write([ |
||
| 85 | [ |
||
| 86 | 'name' => SchemaNS::CBC . 'DocumentCurrencyCode', |
||
| 87 | 'value' => $this->DocumentCurrencyCode, |
||
| 88 | 'attributes' => [ |
||
| 89 | 'listID' => 'ISO 4217 Alpha', |
||
| 90 | 'listName' => 'Currency', |
||
| 91 | 'listAgencyName' => 'United Nations Economic Commission for Europe' |
||
| 92 | ] |
||
| 93 | ], |
||
| 94 | SchemaNS::CBC . 'LineCountNumeric' => $this->LineCountNumeric |
||
| 95 | ]); |
||
| 96 | |||
| 97 | // Order Reference |
||
| 98 | if($this->OrderReference){ |
||
| 99 | $writer->write([ |
||
| 100 | SchemaNS::CAC . 'OrderReference' => $this->OrderReference |
||
| 101 | ]); |
||
| 102 | } |
||
| 103 | |||
| 104 | // Despatch Document Reference |
||
| 105 | if($this->DespatchDocumentReference){ |
||
| 106 | $writer->write([ |
||
| 107 | SchemaNS::CAC . 'DespatchDocumentReference' => $this->DespatchDocumentReference |
||
| 108 | ]); |
||
| 109 | } |
||
| 110 | // cac:Signature |
||
| 111 | $this->writeLineJump($writer); |
||
| 112 | $writer->writeRaw($Signature); |
||
| 113 | $writer->write([ |
||
| 114 | SchemaNS::CAC . 'AccountingSupplierParty' => $this->AccountingSupplierParty, |
||
| 115 | SchemaNS::CAC . 'AccountingCustomerParty' => $this->AccountingCustomerParty |
||
| 116 | ]); |
||
| 117 | // Cargos y descuentos |
||
| 118 | foreach ($this->AllowanceCharges as $AllowanceCharge) { |
||
| 119 | $writer->write([ |
||
| 120 | SchemaNS::CAC . 'AllowanceCharge' => $AllowanceCharge |
||
| 121 | ]); |
||
| 122 | } |
||
| 123 | $writer->write([ |
||
| 124 | SchemaNS::CAC . 'TaxTotal' => $this->TaxTotal |
||
| 125 | ]); |
||
| 126 | $writer->write([ |
||
| 127 | SchemaNS::CAC . 'LegalMonetaryTotal' => $this->LegalMonetaryTotal |
||
| 128 | ]); |
||
| 129 | |||
| 130 | // Detalle |
||
| 131 | foreach ($this->InvoiceLines as $InvoiceLine) { |
||
| 132 | $writer->write([ |
||
| 133 | SchemaNS::CAC . 'InvoiceLine' => $InvoiceLine |
||
| 134 | ]); |
||
| 139 |