Total Complexity | 41 |
Total Lines | 553 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like Thirdparty 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 Thirdparty, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
12 | class Thirdparty |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * @var int |
||
17 | * @JMS\Type("int") |
||
18 | */ |
||
19 | private $id; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | * |
||
24 | * @JMS\Type("string") |
||
25 | */ |
||
26 | private $name; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | * |
||
31 | * @JMS\Type("string") |
||
32 | */ |
||
33 | private $nameAlias; |
||
34 | |||
35 | /** |
||
36 | * @var bool|null |
||
37 | * |
||
38 | * @JMS\Type("boolean") |
||
39 | */ |
||
40 | private $entity; |
||
41 | |||
42 | /** |
||
43 | * Is in activity or not. (Open / Close in Dolibarr). |
||
44 | * |
||
45 | * @var bool |
||
46 | * |
||
47 | * @JMS\SerializedName("status") |
||
48 | * @JMS\Type("boolean") |
||
49 | */ |
||
50 | private $activity; |
||
51 | |||
52 | /** |
||
53 | * @var int |
||
54 | * |
||
55 | * @JMS\SerializedName("client") |
||
56 | * @JMS\Type("integer") |
||
57 | */ |
||
58 | private $type; |
||
59 | |||
60 | /** |
||
61 | * @var string |
||
62 | * |
||
63 | * @JMS\Type("string") |
||
64 | */ |
||
65 | private $address; |
||
66 | |||
67 | /** |
||
68 | * @var string |
||
69 | * |
||
70 | * @JMS\Type("string") |
||
71 | */ |
||
72 | private $zip; |
||
73 | |||
74 | /** |
||
75 | * @var string |
||
76 | * |
||
77 | * @JMS\Type("string") |
||
78 | */ |
||
79 | private $town; |
||
80 | |||
81 | /** |
||
82 | * @var string |
||
83 | * |
||
84 | * @JMS\Type("string") |
||
85 | */ |
||
86 | private $email; |
||
87 | |||
88 | /** |
||
89 | * @var string |
||
90 | * |
||
91 | * @JMS\Type("string") |
||
92 | */ |
||
93 | private $phone; |
||
94 | |||
95 | /** |
||
96 | * @var string |
||
97 | * |
||
98 | * @JMS\Type("string") |
||
99 | */ |
||
100 | private $fax; |
||
101 | |||
102 | /** |
||
103 | * @var string |
||
104 | * |
||
105 | * @JMS\Type("string") |
||
106 | */ |
||
107 | private $twitter; |
||
108 | |||
109 | /** |
||
110 | * @var string |
||
111 | * |
||
112 | * @JMS\Type("string") |
||
113 | */ |
||
114 | private $facebook; |
||
115 | |||
116 | /** |
||
117 | * @var bool |
||
118 | * |
||
119 | * @JMS\Type("boolean") |
||
120 | */ |
||
121 | private $tva_assuj; |
||
122 | |||
123 | /** |
||
124 | * @var string |
||
125 | * |
||
126 | * @JMS\Type("string") |
||
127 | */ |
||
128 | private $tvaIntra; |
||
129 | |||
130 | /** |
||
131 | * @var string |
||
132 | * |
||
133 | * @JMS\SerializedName("ref_ext") |
||
134 | * @JMS\Type("string") |
||
135 | */ |
||
136 | private $externalId; |
||
137 | |||
138 | /** |
||
139 | * @var string |
||
140 | * |
||
141 | * @JMS\Type("string") |
||
142 | */ |
||
143 | private $defaultLang; |
||
144 | |||
145 | /** |
||
146 | * @var string |
||
147 | * |
||
148 | * @JMS\Type("string") |
||
149 | */ |
||
150 | private $codeClient; |
||
151 | |||
152 | /** |
||
153 | * @var string |
||
154 | * |
||
155 | * @JMS\Type("string") |
||
156 | */ |
||
157 | private $codeFournisseur; |
||
158 | |||
159 | public function __construct() |
||
160 | { |
||
161 | $this->tva_assuj = false; |
||
162 | $this->codeClient = -1; //automatically assigned by Dolibarr |
||
163 | $this->codeFournisseur = -1; //automatically assigned by Dolibarr |
||
164 | $this->activity = true; //in activity |
||
165 | } |
||
166 | |||
167 | /** |
||
168 | * @return int |
||
169 | */ |
||
170 | public function getId() |
||
171 | { |
||
172 | return $this->id; |
||
173 | } |
||
174 | |||
175 | /** |
||
176 | * @param int $id |
||
177 | * |
||
178 | * @return Thirdparty |
||
179 | */ |
||
180 | public function setId($id) |
||
181 | { |
||
182 | $this->id = $id; |
||
183 | |||
184 | return $this; |
||
185 | } |
||
186 | |||
187 | /** |
||
188 | * @return string |
||
189 | */ |
||
190 | public function getName() |
||
191 | { |
||
192 | return $this->name; |
||
193 | } |
||
194 | |||
195 | /** |
||
196 | * @param string $name |
||
197 | * |
||
198 | * @return Thirdparty |
||
199 | */ |
||
200 | public function setName($name) |
||
201 | { |
||
202 | $this->name = $name; |
||
203 | |||
204 | return $this; |
||
205 | } |
||
206 | |||
207 | /** |
||
208 | * @return string |
||
209 | */ |
||
210 | public function getNameAlias() |
||
211 | { |
||
212 | return $this->nameAlias; |
||
213 | } |
||
214 | |||
215 | /** |
||
216 | * @param string $nameAlias |
||
217 | * |
||
218 | * @return Thirdparty |
||
219 | */ |
||
220 | public function setNameAlias($nameAlias) |
||
221 | { |
||
222 | $this->nameAlias = $nameAlias; |
||
223 | |||
224 | return $this; |
||
225 | } |
||
226 | |||
227 | /** |
||
228 | * @return bool|null |
||
229 | */ |
||
230 | public function getEntity() |
||
231 | { |
||
232 | return $this->entity; |
||
233 | } |
||
234 | |||
235 | /** |
||
236 | * @param bool|null $entity |
||
237 | * |
||
238 | * @return Thirdparty |
||
239 | */ |
||
240 | public function setEntity($entity) |
||
241 | { |
||
242 | $this->entity = $entity; |
||
243 | |||
244 | return $this; |
||
245 | } |
||
246 | |||
247 | /** |
||
248 | * @return bool |
||
249 | */ |
||
250 | public function isActivity() |
||
251 | { |
||
252 | return $this->activity; |
||
253 | } |
||
254 | |||
255 | /** |
||
256 | * @param bool $activity |
||
257 | * |
||
258 | * @return Thirdparty |
||
259 | */ |
||
260 | public function setActivity($activity) |
||
261 | { |
||
262 | $this->activity = $activity; |
||
263 | |||
264 | return $this; |
||
265 | } |
||
266 | |||
267 | /** |
||
268 | * @return int |
||
269 | */ |
||
270 | public function getType() |
||
271 | { |
||
272 | return $this->type; |
||
273 | } |
||
274 | |||
275 | /** |
||
276 | * @param int $type |
||
277 | * |
||
278 | * @return Thirdparty |
||
279 | */ |
||
280 | public function setType($type) |
||
281 | { |
||
282 | $this->type = $type; |
||
283 | |||
284 | return $this; |
||
285 | } |
||
286 | |||
287 | /** |
||
288 | * @return string |
||
289 | */ |
||
290 | public function getAddress() |
||
291 | { |
||
292 | return $this->address; |
||
293 | } |
||
294 | |||
295 | /** |
||
296 | * @param string $address |
||
297 | * |
||
298 | * @return Thirdparty |
||
299 | */ |
||
300 | public function setAddress($address) |
||
301 | { |
||
302 | $this->address = $address; |
||
303 | |||
304 | return $this; |
||
305 | } |
||
306 | |||
307 | /** |
||
308 | * @return string |
||
309 | */ |
||
310 | public function getZip() |
||
311 | { |
||
312 | return $this->zip; |
||
313 | } |
||
314 | |||
315 | /** |
||
316 | * @param string $zip |
||
317 | * |
||
318 | * @return Thirdparty |
||
319 | */ |
||
320 | public function setZip($zip) |
||
321 | { |
||
322 | $this->zip = $zip; |
||
323 | |||
324 | return $this; |
||
325 | } |
||
326 | |||
327 | /** |
||
328 | * @return string |
||
329 | */ |
||
330 | public function getTown() |
||
331 | { |
||
332 | return $this->town; |
||
333 | } |
||
334 | |||
335 | /** |
||
336 | * @param string $town |
||
337 | * |
||
338 | * @return Thirdparty |
||
339 | */ |
||
340 | public function setTown($town) |
||
341 | { |
||
342 | $this->town = $town; |
||
343 | |||
344 | return $this; |
||
345 | } |
||
346 | |||
347 | /** |
||
348 | * @return string |
||
349 | */ |
||
350 | public function getEmail() |
||
353 | } |
||
354 | |||
355 | /** |
||
356 | * @param string $email |
||
357 | * |
||
358 | * @return Thirdparty |
||
359 | */ |
||
360 | public function setEmail($email) |
||
361 | { |
||
362 | $this->email = $email; |
||
363 | |||
364 | return $this; |
||
365 | } |
||
366 | |||
367 | /** |
||
368 | * @return string |
||
369 | */ |
||
370 | public function getPhone() |
||
371 | { |
||
372 | return $this->phone; |
||
373 | } |
||
374 | |||
375 | /** |
||
376 | * @param string $phone |
||
377 | * |
||
378 | * @return Thirdparty |
||
379 | */ |
||
380 | public function setPhone($phone) |
||
381 | { |
||
382 | $this->phone = $phone; |
||
383 | |||
384 | return $this; |
||
385 | } |
||
386 | |||
387 | /** |
||
388 | * @return string |
||
389 | */ |
||
390 | public function getFax() |
||
391 | { |
||
392 | return $this->fax; |
||
393 | } |
||
394 | |||
395 | /** |
||
396 | * @param string $fax |
||
397 | * |
||
398 | * @return Thirdparty |
||
399 | */ |
||
400 | public function setFax($fax) |
||
401 | { |
||
402 | $this->fax = $fax; |
||
403 | |||
404 | return $this; |
||
405 | } |
||
406 | |||
407 | /** |
||
408 | * @return string |
||
409 | */ |
||
410 | public function getTwitter() |
||
411 | { |
||
412 | return $this->twitter; |
||
413 | } |
||
414 | |||
415 | /** |
||
416 | * @param string $twitter |
||
417 | * |
||
418 | * @return Thirdparty |
||
419 | */ |
||
420 | public function setTwitter($twitter) |
||
421 | { |
||
422 | $this->twitter = $twitter; |
||
423 | |||
424 | return $this; |
||
425 | } |
||
426 | |||
427 | /** |
||
428 | * @return string |
||
429 | */ |
||
430 | public function getFacebook() |
||
431 | { |
||
432 | return $this->facebook; |
||
433 | } |
||
434 | |||
435 | /** |
||
436 | * @param string $facebook |
||
437 | * |
||
438 | * @return Thirdparty |
||
439 | */ |
||
440 | public function setFacebook($facebook) |
||
441 | { |
||
442 | $this->facebook = $facebook; |
||
443 | |||
444 | return $this; |
||
445 | } |
||
446 | |||
447 | /** |
||
448 | * @return bool |
||
449 | */ |
||
450 | public function isTvaAssuj() |
||
451 | { |
||
452 | return $this->tva_assuj; |
||
453 | } |
||
454 | |||
455 | /** |
||
456 | * @param bool $tva_assuj |
||
457 | * |
||
458 | * @return Thirdparty |
||
459 | */ |
||
460 | public function setTvaAssuj($tva_assuj) |
||
461 | { |
||
462 | $this->tva_assuj = $tva_assuj; |
||
463 | |||
464 | return $this; |
||
465 | } |
||
466 | |||
467 | /** |
||
468 | * @return string |
||
469 | */ |
||
470 | public function getTvaIntra() |
||
471 | { |
||
472 | return $this->tvaIntra; |
||
473 | } |
||
474 | |||
475 | /** |
||
476 | * @param string $tvaIntra |
||
477 | * |
||
478 | * @return Thirdparty |
||
479 | */ |
||
480 | public function setTvaIntra($tvaIntra) |
||
485 | } |
||
486 | |||
487 | /** |
||
488 | * @return string |
||
489 | */ |
||
490 | public function getExternalId() |
||
491 | { |
||
492 | return $this->externalId; |
||
493 | } |
||
494 | |||
495 | /** |
||
496 | * @param string $externalId |
||
497 | * |
||
498 | * @return Thirdparty |
||
499 | */ |
||
500 | public function setExternalId($externalId) |
||
501 | { |
||
502 | $this->externalId = $externalId; |
||
503 | |||
504 | return $this; |
||
505 | } |
||
506 | |||
507 | /** |
||
508 | * @return string |
||
509 | */ |
||
510 | public function getDefaultLang() |
||
511 | { |
||
512 | return $this->defaultLang; |
||
513 | } |
||
514 | |||
515 | /** |
||
516 | * @param string $defaultLang |
||
517 | * |
||
518 | * @return Thirdparty |
||
519 | */ |
||
520 | public function setDefaultLang($defaultLang) |
||
521 | { |
||
522 | $this->defaultLang = $defaultLang; |
||
523 | |||
524 | return $this; |
||
525 | } |
||
526 | |||
527 | /** |
||
528 | * @return string |
||
529 | */ |
||
530 | public function getCodeClient() |
||
531 | { |
||
532 | return $this->codeClient; |
||
533 | } |
||
534 | |||
535 | /** |
||
536 | * @param string $codeClient |
||
537 | * |
||
538 | * @return Thirdparty |
||
539 | */ |
||
540 | public function setCodeClient($codeClient) |
||
541 | { |
||
542 | $this->codeClient = $codeClient; |
||
543 | |||
544 | return $this; |
||
545 | } |
||
546 | |||
547 | /** |
||
548 | * @return string |
||
549 | */ |
||
550 | public function getCodeFournisseur() |
||
553 | } |
||
554 | |||
555 | /** |
||
556 | * @param string $codeFournisseur |
||
557 | * |
||
558 | * @return Thirdparty |
||
559 | */ |
||
560 | public function setCodeFournisseur($codeFournisseur) |
||
561 | { |
||
562 | $this->codeFournisseur = $codeFournisseur; |
||
563 | |||
564 | return $this; |
||
565 | } |
||
566 | } |
||
567 |