Complex classes like BankwireDirectPayIn 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
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 BankwireDirectPayIn, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
15 | class BankwireDirectPayIn |
||
16 | { |
||
17 | private $resourceId; |
||
18 | |||
19 | private $tag; |
||
20 | |||
21 | private $authorId; |
||
22 | |||
23 | private $creditedWalletId; |
||
24 | |||
25 | private $creditedUserId; |
||
26 | |||
27 | private $declaredDebitedFundsCurrency; |
||
28 | |||
29 | private $declaredDebitedFundsAmount; |
||
30 | |||
31 | private $declaredFeesCurrency; |
||
32 | |||
33 | private $declaredFeesAmount; |
||
34 | |||
35 | private $status; |
||
36 | |||
37 | private $resultCode; |
||
38 | |||
39 | private $resultMessage; |
||
40 | |||
41 | private $type; |
||
42 | |||
43 | private $nature; |
||
44 | |||
45 | private $paymentType; |
||
46 | |||
47 | private $executionType; |
||
48 | |||
49 | private $wireReference; |
||
50 | |||
51 | private $bankAccountType; |
||
52 | |||
53 | private $bankAccountOwnerName; |
||
54 | |||
55 | private $bankAccountIban; |
||
56 | |||
57 | private $bankAccountBic; |
||
58 | |||
59 | public function getAmount() |
||
60 | { |
||
61 | return $this->getDeclaredDebitedFundsAmount(); |
||
62 | } |
||
63 | /** |
||
64 | * @return mixed |
||
65 | */ |
||
66 | public function getTag() |
||
70 | |||
71 | /** |
||
72 | * @param mixed $tag |
||
73 | */ |
||
74 | public function setTag($tag) |
||
78 | |||
79 | /** |
||
80 | * @return mixed |
||
81 | */ |
||
82 | public function getAuthorId() |
||
86 | |||
87 | /** |
||
88 | * @param mixed $authorId |
||
89 | */ |
||
90 | public function setAuthorId($authorId) |
||
94 | |||
95 | /** |
||
96 | * @return mixed |
||
97 | */ |
||
98 | public function getCreditedWalletId() |
||
102 | |||
103 | /** |
||
104 | * @param mixed $creditedWalletId |
||
105 | */ |
||
106 | public function setCreditedWalletId($creditedWalletId) |
||
110 | |||
111 | /** |
||
112 | * @return mixed |
||
113 | */ |
||
114 | public function getCreditedUserId() |
||
118 | |||
119 | /** |
||
120 | * @param mixed $creditedUserId |
||
121 | */ |
||
122 | public function setCreditedUserId($creditedUserId) |
||
126 | |||
127 | /** |
||
128 | * @return mixed |
||
129 | */ |
||
130 | public function getDeclaredDebitedFundsCurrency() |
||
134 | |||
135 | /** |
||
136 | * @param mixed $declaredDebitedFundsCurrency |
||
137 | */ |
||
138 | public function setDeclaredDebitedFundsCurrency($declaredDebitedFundsCurrency) |
||
142 | |||
143 | /** |
||
144 | * @return mixed |
||
145 | */ |
||
146 | public function getDeclaredDebitedFundsAmount() |
||
150 | |||
151 | /** |
||
152 | * @param mixed $declaredDebitedFundsAmount |
||
153 | */ |
||
154 | public function setDeclaredDebitedFundsAmount($declaredDebitedFundsAmount) |
||
158 | |||
159 | /** |
||
160 | * @return mixed |
||
161 | */ |
||
162 | public function getDeclaredFeesCurrency() |
||
166 | |||
167 | /** |
||
168 | * @param mixed $declaredFeesCurrency |
||
169 | */ |
||
170 | public function setDeclaredFeesCurrency($declaredFeesCurrency) |
||
174 | |||
175 | /** |
||
176 | * @return mixed |
||
177 | */ |
||
178 | public function getDeclaredFeesAmount() |
||
182 | |||
183 | /** |
||
184 | * @param mixed $declaredFeesAmount |
||
185 | */ |
||
186 | public function setDeclaredFeesAmount($declaredFeesAmount) |
||
190 | |||
191 | /** |
||
192 | * @return mixed |
||
193 | */ |
||
194 | public function getStatus() |
||
198 | |||
199 | /** |
||
200 | * @param mixed $status |
||
201 | */ |
||
202 | public function setStatus($status) |
||
206 | |||
207 | /** |
||
208 | * @return mixed |
||
209 | */ |
||
210 | public function getResultCode() |
||
214 | |||
215 | /** |
||
216 | * @param mixed $resultCode |
||
217 | */ |
||
218 | public function setResultCode($resultCode) |
||
222 | |||
223 | /** |
||
224 | * @return mixed |
||
225 | */ |
||
226 | public function getResultMessage() |
||
230 | |||
231 | /** |
||
232 | * @param mixed $resultMessage |
||
233 | */ |
||
234 | public function setResultMessage($resultMessage) |
||
238 | |||
239 | /** |
||
240 | * @return mixed |
||
241 | */ |
||
242 | public function getType() |
||
246 | |||
247 | /** |
||
248 | * @param mixed $type |
||
249 | */ |
||
250 | public function setType($type) |
||
254 | |||
255 | /** |
||
256 | * @return mixed |
||
257 | */ |
||
258 | public function getNature() |
||
262 | |||
263 | /** |
||
264 | * @param mixed $nature |
||
265 | */ |
||
266 | public function setNature($nature) |
||
270 | |||
271 | /** |
||
272 | * @return mixed |
||
273 | */ |
||
274 | public function getPaymentType() |
||
278 | |||
279 | /** |
||
280 | * @param mixed $paymentType |
||
281 | */ |
||
282 | public function setPaymentType($paymentType) |
||
286 | |||
287 | /** |
||
288 | * @return mixed |
||
289 | */ |
||
290 | public function getExecutionType() |
||
294 | |||
295 | /** |
||
296 | * @param mixed $executionType |
||
297 | */ |
||
298 | public function setExecutionType($executionType) |
||
302 | |||
303 | /** |
||
304 | * @return mixed |
||
305 | */ |
||
306 | public function getWireReference() |
||
310 | |||
311 | /** |
||
312 | * @param mixed $wireReference |
||
313 | */ |
||
314 | public function setWireReference($wireReference) |
||
318 | |||
319 | /** |
||
320 | * @return mixed |
||
321 | */ |
||
322 | public function getBankAccountType() |
||
326 | |||
327 | /** |
||
328 | * @param mixed $bankAccountType |
||
329 | */ |
||
330 | public function setBankAccountType($bankAccountType) |
||
334 | |||
335 | /** |
||
336 | * @return mixed |
||
337 | */ |
||
338 | public function getBankAccountOwnerName() |
||
342 | |||
343 | /** |
||
344 | * @param mixed $bankAccountOwnerName |
||
345 | */ |
||
346 | public function setBankAccountOwnerName($bankAccountOwnerName) |
||
350 | |||
351 | /** |
||
352 | * @return mixed |
||
353 | */ |
||
354 | public function getBankAccountIban() |
||
358 | |||
359 | /** |
||
360 | * @param mixed $bankAccountIban |
||
361 | */ |
||
362 | public function setBankAccountIban($bankAccountIban) |
||
366 | |||
367 | /** |
||
368 | * @return mixed |
||
369 | */ |
||
370 | public function getBankAccountBic() |
||
374 | |||
375 | /** |
||
376 | * @param mixed $bankAccountBic |
||
377 | */ |
||
378 | public function setBankAccountBic($bankAccountBic) |
||
382 | |||
383 | /** |
||
384 | * @return mixed |
||
385 | */ |
||
386 | public function getResourceId() |
||
390 | |||
391 | /** |
||
392 | * @param mixed $resourceId |
||
393 | */ |
||
394 | public function setResourceId($resourceId) |
||
398 | } |
||
399 |