Total Complexity | 41 |
Total Lines | 240 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
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 |
||
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() { |
||
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) { |
||
194 | } |
||
195 | |||
196 | public function getAllowanceCharges() { |
||
197 | return $this->AllowanceCharges; |
||
198 | } |
||
199 | |||
200 | public function setAllowanceCharges(array $AllowanceCharges) { |
||
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() { |
||
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 |