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