Invoice   A
last analyzed

Complexity

Total Complexity 41

Size/Duplication

Total Lines 240
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 79
dl 0
loc 240
rs 9.1199
c 1
b 0
f 0
wmc 41

41 Methods

Rating   Name   Duplication   Size   Complexity  
A getProfileID() 0 2 1
A setDespatchDocumentReference() 0 2 1
A getID() 0 2 1
A setDocumentCurrencyCode() 0 3 1
A setNotes() 0 3 1
A setAllowanceCharges() 0 3 1
A setAccountingCustomerParty() 0 3 1
A getInvoiceTypeCode() 0 2 1
A getInvoiceLines() 0 2 1
A addAllowanceCharge() 0 3 1
A setOrderReference() 0 2 1
A setPaymentTerms() 0 3 1
A getOrderReference() 0 2 1
A getTaxTotal() 0 2 1
A setSignature() 0 3 1
A getLineCountNumeric() 0 2 1
A getAccountingSupplierParty() 0 2 1
A getDueDate() 0 2 1
A setID() 0 3 1
A setProfileID() 0 3 1
A getSignature() 0 2 1
A getAllowanceCharges() 0 2 1
A getLegalMonetaryTotal() 0 2 1
A setLegalMonetaryTotal() 0 3 1
A setInvoiceLines() 0 3 1
A setTaxTotal() 0 3 1
A getDocumentCurrencyCode() 0 2 1
A setInvoiceTypeCode() 0 3 1
A getPaymentTerms() 0 2 1
A getIssueDate() 0 2 1
A setDueDate() 0 2 1
A setAccountingSupplierParty() 0 3 1
A getAccountingCustomerParty() 0 2 1
A setLineCountNumeric() 0 2 1
A getUBLExtensions() 0 2 1
A setUBLExtensions() 0 3 1
A getDespatchDocumentReference() 0 2 1
A addNote() 0 3 1
A getNotes() 0 2 1
A setIssueDate() 0 2 1
A addInvoiceLine() 0 3 1

How to fix   Complexity   

Complex Class

Complex classes like Invoice often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Invoice, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/**
4
 * MÓDULO DE EMISIÓN ELECTRÓNICA F72X
5
 * UBL 2.1
6
 * Version 1.0
7
 *
8
 * Copyright 2019, Jaime Cruz
9
 */
10
namespace F72X\UblComponent;
11
12
use DateTime;
13
14
abstract class Invoice extends BaseComponent {
15
16
    /** @var UBLExtensions */
17
    protected $UBLExtensions;
18
    protected $ProfileID;
19
    protected $ID;
20
21
22
    /** @var DateTime */
23
    protected $IssueDate;
24
25
    /** @var DateTime */
26
    protected $DueDate;
27
    protected $InvoiceTypeCode;
28
29
    /** @var Note[] */
30
    protected $Notes = [];
31
    protected $DocumentCurrencyCode;
32
    protected $languageLocaleID;
33
    protected $LineCountNumeric;
34
35
    /** @var OrderReference */
36
    protected $OrderReference;
37
38
    /** @var Signature */
39
    protected $Signature;
40
41
    /** @var AccountingSupplierParty */
42
    protected $AccountingSupplierParty;
43
44
    /** @var AccountingCustomerParty */
45
    protected $AccountingCustomerParty;
46
47
    /** @var DespatchDocumentReference */
48
    protected $DespatchDocumentReference;
49
50
    /** @var AllowanceCharge[] */
51
    protected $AllowanceCharges = [];
52
53
    /** @var PaymentTerms[] */
54
    protected $PaymentTerms = [];
55
56
    /** @var TaxTotal */
57
    protected $TaxTotal;
58
59
    /** @var LegalMonetaryTotal */
60
    protected $LegalMonetaryTotal;
61
62
    /** @var InvoiceLine[] */
63
    protected $InvoiceLines = [];
64
65
    public function getUBLExtensions() {
66
        return $this->UBLExtensions;
67
    }
68
69
    public function setUBLExtensions($UBLExtensions) {
70
        $this->UBLExtensions = $UBLExtensions;
71
        return $this;
72
    }
73
74
    public function getProfileID() {
75
        return $this->ProfileID;
76
    }
77
78
    public function setProfileID($ProfileID) {
79
        $this->ProfileID = $ProfileID;
80
        return $this;
81
    }
82
83
    public function getID() {
84
        return $this->ID;
85
    }
86
87
    public function setID($ID) {
88
        $this->ID = $ID;
89
        return $this;
90
    }
91
92
    public function getIssueDate() {
93
        return $this->IssueDate;
94
    }
95
96
    public function setIssueDate(DateTime $IssueDate) {
97
        $this->IssueDate = $IssueDate;
98
    }
99
100
    public function getDueDate() {
101
        return $this->DueDate;
102
    }
103
104
    public function setDueDate(DateTime $DueDate) {
105
        $this->DueDate = $DueDate;
106
    }
107
108
    public function getInvoiceTypeCode() {
109
        return $this->InvoiceTypeCode;
110
    }
111
112
    public function setInvoiceTypeCode($InvoiceTypeCode) {
113
        $this->InvoiceTypeCode = $InvoiceTypeCode;
114
        return $this;
115
    }
116
117
    public function getNotes() {
118
        return $this->Notes;
119
    }
120
121
    public function setNotes($Notes) {
122
        $this->Notes = $Notes;
123
        return $this;
124
    }
125
126
    /**
127
     *
128
     * @param Note $Note
129
     * @return $this
130
     */
131
    public function addNote(Note $Note) {
132
        $this->Notes[] = $Note;
133
        return $this;
134
    }
135
136
    public function getDocumentCurrencyCode() {
137
        return $this->DocumentCurrencyCode;
138
    }
139
140
    public function setDocumentCurrencyCode($DocumentCurrencyCode) {
141
        $this->DocumentCurrencyCode = $DocumentCurrencyCode;
142
        return $this;
143
    }
144
145
    public function getLineCountNumeric() {
146
        return $this->LineCountNumeric;
147
    }
148
149
    public function setLineCountNumeric($LineCountNumeric) {
150
        $this->LineCountNumeric = $LineCountNumeric;
151
    }
152
153
    public function getOrderReference() {
154
        return $this->OrderReference;
155
    }
156
157
    public function setOrderReference(OrderReference $OrderReference) {
158
        $this->OrderReference = $OrderReference;
159
    }
160
161
    public function getSignature() {
162
        return $this->Signature;
163
    }
164
165
    public function setSignature(Signature $Signature) {
166
        $this->Signature = $Signature;
167
        return $this;
168
    }
169
170
    public function getAccountingSupplierParty() {
171
        return $this->AccountingSupplierParty;
172
    }
173
174
    public function setAccountingSupplierParty(AccountingSupplierParty $AccountingSupplierParty) {
175
        $this->AccountingSupplierParty = $AccountingSupplierParty;
176
        return $this;
177
    }
178
179
    public function getAccountingCustomerParty() {
180
        return $this->AccountingCustomerParty;
181
    }
182
183
    public function setAccountingCustomerParty(AccountingCustomerParty $AccountingCustomerParty) {
184
        $this->AccountingCustomerParty = $AccountingCustomerParty;
185
        return $this;
186
    }
187
188
    public function getDespatchDocumentReference() {
189
        return $this->DespatchDocumentReference;
190
    }
191
192
    public function setDespatchDocumentReference(DespatchDocumentReference $DespatchDocumentReference) {
193
        $this->DespatchDocumentReference = $DespatchDocumentReference;
194
    }
195
196
    public function getAllowanceCharges() {
197
        return $this->AllowanceCharges;
198
    }
199
200
    public function setAllowanceCharges(array $AllowanceCharges) {
201
        $this->AllowanceCharges = $AllowanceCharges;
202
        return $this;
203
    }
204
205
    /**
206
     *
207
     * @param AllowanceCharge $AllowanceCharge
208
     * @return $this
209
     */
210
    public function addAllowanceCharge(AllowanceCharge $AllowanceCharge) {
211
        $this->AllowanceCharges[] = $AllowanceCharge;
212
        return $this;
213
    }
214
215
    public function getPaymentTerms() {
216
        return $this->PaymentTerms;
217
    }
218
219
    public function setPaymentTerms($PaymentTerms) {
220
        $this->PaymentTerms = $PaymentTerms;
221
        return $this;
222
    }
223
224
    public function getTaxTotal() {
225
        return $this->TaxTotal;
226
    }
227
228
    public function setTaxTotal(TaxTotal $TaxTotal) {
229
        $this->TaxTotal = $TaxTotal;
230
        return $this;
231
    }
232
233
    public function getLegalMonetaryTotal() {
234
        return $this->LegalMonetaryTotal;
235
    }
236
237
    public function setLegalMonetaryTotal(LegalMonetaryTotal $LegalMonetaryTotal) {
238
        $this->LegalMonetaryTotal = $LegalMonetaryTotal;
239
        return $this;
240
    }
241
242
    public function getInvoiceLines() {
243
        return $this->InvoiceLines;
244
    }
245
246
    public function setInvoiceLines($InvoiceLines) {
247
        $this->InvoiceLines = $InvoiceLines;
248
        return $this;
249
    }
250
251
    public function addInvoiceLine(InvoiceLine $InvoiceLine) {
252
        $this->InvoiceLines[] = $InvoiceLine;
253
        return $this;
254
    }
255
256
}
257