Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Contact 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 Contact, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
85 | class Contact extends ExtendContact implements EmailOwnerInterface |
||
86 | { |
||
87 | /* |
||
88 | * Fields have to be duplicated here to enable dataaudit and soap transformation only for contact |
||
89 | */ |
||
90 | /** |
||
91 | * @var int |
||
92 | * |
||
93 | * @ORM\Id |
||
94 | * @ORM\Column(type="integer", name="id") |
||
95 | * @ORM\GeneratedValue(strategy="AUTO") |
||
96 | * @Soap\ComplexType("int", nillable=true) |
||
97 | * @ConfigField( |
||
98 | * defaultValues={ |
||
99 | * "importexport"={ |
||
100 | * "order"=10 |
||
101 | * } |
||
102 | * } |
||
103 | * ) |
||
104 | */ |
||
105 | protected $id; |
||
106 | |||
107 | /** |
||
108 | * @var string |
||
109 | * |
||
110 | * @ORM\Column(name="name_prefix", type="string", length=255, nullable=true) |
||
111 | * @Soap\ComplexType("string", nillable=true) |
||
112 | * @ConfigField( |
||
113 | * defaultValues={ |
||
114 | * "dataaudit"={ |
||
115 | * "auditable"=true |
||
116 | * }, |
||
117 | * "importexport"={ |
||
118 | * "order"=20 |
||
119 | * }, |
||
120 | * "merge"={ |
||
121 | * "display"=true |
||
122 | * } |
||
123 | * } |
||
124 | * ) |
||
125 | */ |
||
126 | protected $namePrefix; |
||
127 | |||
128 | /** |
||
129 | * @var string |
||
130 | * |
||
131 | * @ORM\Column(name="first_name", type="string", length=255, nullable=true) |
||
132 | * @Soap\ComplexType("string", nillable=true) |
||
133 | * @ConfigField( |
||
134 | * defaultValues={ |
||
135 | * "dataaudit"={ |
||
136 | * "auditable"=true |
||
137 | * }, |
||
138 | * "importexport"={ |
||
139 | * "identity"=true, |
||
140 | * "order"=30 |
||
141 | * }, |
||
142 | * "merge"={ |
||
143 | * "display"=true |
||
144 | * } |
||
145 | * } |
||
146 | * ) |
||
147 | */ |
||
148 | protected $firstName; |
||
149 | |||
150 | /** |
||
151 | * @var string |
||
152 | * |
||
153 | * @ORM\Column(name="middle_name", type="string", length=255, nullable=true) |
||
154 | * @Soap\ComplexType("string", nillable=true) |
||
155 | * @ConfigField( |
||
156 | * defaultValues={ |
||
157 | * "dataaudit"={ |
||
158 | * "auditable"=true |
||
159 | * }, |
||
160 | * "importexport"={ |
||
161 | * "order"=40 |
||
162 | * }, |
||
163 | * "merge"={ |
||
164 | * "display"=true |
||
165 | * } |
||
166 | * } |
||
167 | * ) |
||
168 | */ |
||
169 | protected $middleName; |
||
170 | |||
171 | /** |
||
172 | * @var string |
||
173 | * |
||
174 | * @ORM\Column(name="last_name", type="string", length=255, nullable=true) |
||
175 | * @Soap\ComplexType("string", nillable=true) |
||
176 | * @ConfigField( |
||
177 | * defaultValues={ |
||
178 | * "dataaudit"={ |
||
179 | * "auditable"=true |
||
180 | * }, |
||
181 | * "importexport"={ |
||
182 | * "identity"=true, |
||
183 | * "order"=50 |
||
184 | * }, |
||
185 | * "merge"={ |
||
186 | * "display"=true |
||
187 | * } |
||
188 | * } |
||
189 | * ) |
||
190 | */ |
||
191 | protected $lastName; |
||
192 | |||
193 | /** |
||
194 | * @var string |
||
195 | * |
||
196 | * @ORM\Column(name="name_suffix", type="string", length=255, nullable=true) |
||
197 | * @Soap\ComplexType("string", nillable=true) |
||
198 | * @ConfigField( |
||
199 | * defaultValues={ |
||
200 | * "dataaudit"={ |
||
201 | * "auditable"=true |
||
202 | * }, |
||
203 | * "importexport"={ |
||
204 | * "order"=60 |
||
205 | * }, |
||
206 | * "merge"={ |
||
207 | * "display"=true |
||
208 | * } |
||
209 | * } |
||
210 | * ) |
||
211 | */ |
||
212 | protected $nameSuffix; |
||
213 | |||
214 | /** |
||
215 | * @var string |
||
216 | * |
||
217 | * @ORM\Column(name="gender", type="string", length=8, nullable=true) |
||
218 | * @Soap\ComplexType("string", nillable=true) |
||
219 | * @ConfigField( |
||
220 | * defaultValues={ |
||
221 | * "dataaudit"={ |
||
222 | * "auditable"=true |
||
223 | * }, |
||
224 | * "importexport"={ |
||
225 | * "order"=70 |
||
226 | * }, |
||
227 | * "merge"={ |
||
228 | * "display"=true |
||
229 | * } |
||
230 | * } |
||
231 | * ) |
||
232 | */ |
||
233 | protected $gender; |
||
234 | |||
235 | /** |
||
236 | * @var \DateTime |
||
237 | * |
||
238 | * @ORM\Column(name="birthday", type="date", nullable=true) |
||
239 | * @Soap\ComplexType("date", nillable=true) |
||
240 | * @ConfigField( |
||
241 | * defaultValues={ |
||
242 | * "dataaudit"={ |
||
243 | * "auditable"=true |
||
244 | * }, |
||
245 | * "importexport"={ |
||
246 | * "order"=160 |
||
247 | * }, |
||
248 | * "merge"={ |
||
249 | * "display"=true |
||
250 | * } |
||
251 | * } |
||
252 | * ) |
||
253 | */ |
||
254 | protected $birthday; |
||
255 | |||
256 | /** |
||
257 | * @var string |
||
258 | * |
||
259 | * @ORM\Column(name="description", type="text", nullable=true) |
||
260 | * @Soap\ComplexType("string", nillable=true) |
||
261 | * @ConfigField( |
||
262 | * defaultValues={ |
||
263 | * "dataaudit"={ |
||
264 | * "auditable"=true |
||
265 | * }, |
||
266 | * "importexport"={ |
||
267 | * "order"=80 |
||
268 | * }, |
||
269 | * "merge"={ |
||
270 | * "display"=true, |
||
271 | * "autoescape"=false |
||
272 | * } |
||
273 | * } |
||
274 | * ) |
||
275 | */ |
||
276 | protected $description; |
||
277 | |||
278 | /** |
||
279 | * @var Source |
||
280 | * |
||
281 | * @ORM\ManyToOne(targetEntity="Oro\Bundle\ContactBundle\Entity\Source") |
||
282 | * @ORM\JoinColumn(name="source_name", referencedColumnName="name") |
||
283 | * @ConfigField( |
||
284 | * defaultValues={ |
||
285 | * "dataaudit"={ |
||
286 | * "auditable"=true |
||
287 | * }, |
||
288 | * "importexport"={ |
||
289 | * "order"=170 |
||
290 | * }, |
||
291 | * "merge"={ |
||
292 | * "display"=true |
||
293 | * } |
||
294 | * } |
||
295 | * ) |
||
296 | **/ |
||
297 | protected $source; |
||
298 | |||
299 | /** |
||
300 | * @var Method |
||
301 | * |
||
302 | * @ORM\ManyToOne(targetEntity="Oro\Bundle\ContactBundle\Entity\Method") |
||
303 | * @ORM\JoinColumn(name="method_name", referencedColumnName="name") |
||
304 | * @ConfigField( |
||
305 | * defaultValues={ |
||
306 | * "dataaudit"={ |
||
307 | * "auditable"=true |
||
308 | * }, |
||
309 | * "importexport"={ |
||
310 | * "order"=180 |
||
311 | * }, |
||
312 | * "merge"={ |
||
313 | * "display"=true |
||
314 | * } |
||
315 | * } |
||
316 | * ) |
||
317 | **/ |
||
318 | protected $method; |
||
319 | |||
320 | /** |
||
321 | * @var User |
||
322 | * |
||
323 | * @ORM\ManyToOne(targetEntity="Oro\Bundle\UserBundle\Entity\User") |
||
324 | * @ORM\JoinColumn(name="user_owner_id", referencedColumnName="id", onDelete="SET NULL") |
||
325 | * @Soap\ComplexType("string", nillable=true) |
||
326 | * @ConfigField( |
||
327 | * defaultValues={ |
||
328 | * "dataaudit"={ |
||
329 | * "auditable"=true |
||
330 | * }, |
||
331 | * "importexport"={ |
||
332 | * "order"=190, |
||
333 | * "short"=true |
||
334 | * }, |
||
335 | * "merge"={ |
||
336 | * "display"=true |
||
337 | * } |
||
338 | * } |
||
339 | * ) |
||
340 | */ |
||
341 | protected $owner; |
||
342 | |||
343 | /** |
||
344 | * @var User |
||
345 | * |
||
346 | * @ORM\ManyToOne(targetEntity="Oro\Bundle\UserBundle\Entity\User") |
||
347 | * @ORM\JoinColumn(name="assigned_to_user_id", referencedColumnName="id", onDelete="SET NULL") |
||
348 | * @ConfigField( |
||
349 | * defaultValues={ |
||
350 | * "dataaudit"={ |
||
351 | * "auditable"=true |
||
352 | * }, |
||
353 | * "importexport"={ |
||
354 | * "order"=200, |
||
355 | * "short"=true |
||
356 | * }, |
||
357 | * "merge"={ |
||
358 | * "display"=true |
||
359 | * } |
||
360 | * } |
||
361 | * ) |
||
362 | */ |
||
363 | protected $assignedTo; |
||
364 | |||
365 | /** |
||
366 | * @var Contact |
||
367 | * |
||
368 | * @ORM\ManyToOne(targetEntity="Oro\Bundle\ContactBundle\Entity\Contact") |
||
369 | * @ORM\JoinColumn(name="reports_to_contact_id", referencedColumnName="id", onDelete="SET NULL") |
||
370 | * @ConfigField( |
||
371 | * defaultValues={ |
||
372 | * "dataaudit"={ |
||
373 | * "auditable"=true |
||
374 | * }, |
||
375 | * "importexport"={ |
||
376 | * "excluded"=true |
||
377 | * }, |
||
378 | * "merge"={ |
||
379 | * "display"=true |
||
380 | * } |
||
381 | * } |
||
382 | * ) |
||
383 | */ |
||
384 | protected $reportsTo; |
||
385 | |||
386 | /** |
||
387 | * @var string |
||
388 | * |
||
389 | * @ORM\Column(name="job_title", type="string", length=255, nullable=true) |
||
390 | * @Soap\ComplexType("string", nillable=true) |
||
391 | * @ConfigField( |
||
392 | * defaultValues={ |
||
393 | * "dataaudit"={ |
||
394 | * "auditable"=true |
||
395 | * }, |
||
396 | * "importexport"={ |
||
397 | * "order"=90 |
||
398 | * }, |
||
399 | * "merge"={ |
||
400 | * "display"=true |
||
401 | * } |
||
402 | * } |
||
403 | * ) |
||
404 | */ |
||
405 | protected $jobTitle; |
||
406 | |||
407 | /** |
||
408 | * @var string |
||
409 | * |
||
410 | * @ORM\Column(name="email", type="string", length=255, nullable=true) |
||
411 | * @ConfigField( |
||
412 | * defaultValues={ |
||
413 | * "dataaudit"={ |
||
414 | * "auditable"=true |
||
415 | * }, |
||
416 | * "entity"={ |
||
417 | * "contact_information"="email" |
||
418 | * } |
||
419 | * } |
||
420 | * ) |
||
421 | */ |
||
422 | protected $email; |
||
423 | |||
424 | /** |
||
425 | * @var Collection |
||
426 | * |
||
427 | * @ORM\OneToMany(targetEntity="Oro\Bundle\ContactBundle\Entity\ContactEmail", |
||
428 | * mappedBy="owner", cascade={"all"}, orphanRemoval=true |
||
429 | * ) |
||
430 | * @ORM\OrderBy({"primary" = "DESC"}) |
||
431 | * @Soap\ComplexType("Oro\Bundle\ContactBundle\Entity\ContactEmail[]", nillable=true) |
||
432 | * @ConfigField( |
||
433 | * defaultValues={ |
||
434 | * "importexport"={ |
||
435 | * "order"=210 |
||
436 | * }, |
||
437 | * "dataaudit"={ |
||
438 | * "auditable"=true |
||
439 | * }, |
||
440 | * "merge"={ |
||
441 | * "display"=true |
||
442 | * } |
||
443 | * } |
||
444 | * ) |
||
445 | */ |
||
446 | protected $emails; |
||
447 | |||
448 | /** |
||
449 | * @var Collection |
||
450 | * |
||
451 | * @ORM\OneToMany(targetEntity="Oro\Bundle\ContactBundle\Entity\ContactPhone", mappedBy="owner", |
||
452 | * mappedBy="owner", cascade={"all"}, orphanRemoval=true |
||
453 | * )) |
||
454 | * @ORM\OrderBy({"primary" = "DESC"}) |
||
455 | * @Soap\ComplexType("Oro\Bundle\ContactBundle\Entity\ContactPhone[]", nillable=true) |
||
456 | * @ConfigField( |
||
457 | * defaultValues={ |
||
458 | * "importexport"={ |
||
459 | * "order"=220 |
||
460 | * }, |
||
461 | * "dataaudit"={ |
||
462 | * "auditable"=true |
||
463 | * }, |
||
464 | * "merge"={ |
||
465 | * "display"=true |
||
466 | * } |
||
467 | * } |
||
468 | * ) |
||
469 | */ |
||
470 | protected $phones; |
||
471 | |||
472 | /** |
||
473 | * @var string |
||
474 | * |
||
475 | * @ORM\Column(name="fax", type="string", length=255, nullable=true) |
||
476 | * @Soap\ComplexType("string", nillable=true) |
||
477 | * @ConfigField( |
||
478 | * defaultValues={ |
||
479 | * "dataaudit"={ |
||
480 | * "auditable"=true |
||
481 | * }, |
||
482 | * "importexport"={ |
||
483 | * "order"=100 |
||
484 | * }, |
||
485 | * "merge"={ |
||
486 | * "display"=true |
||
487 | * } |
||
488 | * } |
||
489 | * ) |
||
490 | */ |
||
491 | protected $fax; |
||
492 | |||
493 | /** |
||
494 | * @var string |
||
495 | * |
||
496 | * @ORM\Column(name="skype", type="string", length=255, nullable=true) |
||
497 | * @Soap\ComplexType("string", nillable=true) |
||
498 | * @ConfigField( |
||
499 | * defaultValues={ |
||
500 | * "dataaudit"={ |
||
501 | * "auditable"=true |
||
502 | * }, |
||
503 | * "importexport"={ |
||
504 | * "order"=110 |
||
505 | * }, |
||
506 | * "merge"={ |
||
507 | * "display"=true |
||
508 | * } |
||
509 | * } |
||
510 | * ) |
||
511 | */ |
||
512 | protected $skype; |
||
513 | |||
514 | /** |
||
515 | * @var string |
||
516 | * |
||
517 | * @ORM\Column(name="twitter", type="string", length=255, nullable=true) |
||
518 | * @Soap\ComplexType("string", nillable=true) |
||
519 | * @ConfigField( |
||
520 | * defaultValues={ |
||
521 | * "dataaudit"={ |
||
522 | * "auditable"=true |
||
523 | * }, |
||
524 | * "importexport"={ |
||
525 | * "order"=120 |
||
526 | * }, |
||
527 | * "merge"={ |
||
528 | * "display"=true |
||
529 | * } |
||
530 | * } |
||
531 | * ) |
||
532 | */ |
||
533 | protected $twitter; |
||
534 | |||
535 | /** |
||
536 | * @var string |
||
537 | * |
||
538 | * @ORM\Column(name="facebook", type="string", length=255, nullable=true) |
||
539 | * @Soap\ComplexType("string", nillable=true) |
||
540 | * @ConfigField( |
||
541 | * defaultValues={ |
||
542 | * "dataaudit"={ |
||
543 | * "auditable"=true |
||
544 | * }, |
||
545 | * "importexport"={ |
||
546 | * "order"=130 |
||
547 | * }, |
||
548 | * "merge"={ |
||
549 | * "display"=true |
||
550 | * } |
||
551 | * } |
||
552 | * ) |
||
553 | */ |
||
554 | protected $facebook; |
||
555 | |||
556 | /** |
||
557 | * @var string |
||
558 | * |
||
559 | * @ORM\Column(name="google_plus", type="string", length=255, nullable=true) |
||
560 | * @Soap\ComplexType("string", nillable=true) |
||
561 | * @ConfigField( |
||
562 | * defaultValues={ |
||
563 | * "dataaudit"={ |
||
564 | * "auditable"=true |
||
565 | * }, |
||
566 | * "importexport"={ |
||
567 | * "order"=140 |
||
568 | * }, |
||
569 | * "merge"={ |
||
570 | * "display"=true |
||
571 | * } |
||
572 | * } |
||
573 | * ) |
||
574 | */ |
||
575 | protected $googlePlus; |
||
576 | |||
577 | /** |
||
578 | * @var string |
||
579 | * |
||
580 | * @ORM\Column(name="linkedin", type="string", length=255, nullable=true) |
||
581 | * @Soap\ComplexType("string", nillable=true) |
||
582 | * @ConfigField( |
||
583 | * defaultValues={ |
||
584 | * "dataaudit"={ |
||
585 | * "auditable"=true |
||
586 | * }, |
||
587 | * "importexport"={ |
||
588 | * "order"=150 |
||
589 | * }, |
||
590 | * "merge"={ |
||
591 | * "display"=true |
||
592 | * } |
||
593 | * } |
||
594 | * ) |
||
595 | */ |
||
596 | protected $linkedIn; |
||
597 | |||
598 | /** |
||
599 | * @var Collection |
||
600 | * |
||
601 | * @ORM\OneToMany(targetEntity="Oro\Bundle\ContactBundle\Entity\ContactAddress", |
||
602 | * mappedBy="owner", cascade={"all"}, orphanRemoval=true |
||
603 | * ) |
||
604 | * @ORM\OrderBy({"primary" = "DESC"}) |
||
605 | * @ConfigField( |
||
606 | * defaultValues={ |
||
607 | * "importexport"={ |
||
608 | * "full"=true, |
||
609 | * "order"=250 |
||
610 | * }, |
||
611 | * "dataaudit"={ |
||
612 | * "auditable"=true |
||
613 | * }, |
||
614 | * "merge"={ |
||
615 | * "display"=true |
||
616 | * } |
||
617 | * } |
||
618 | * ) |
||
619 | */ |
||
620 | protected $addresses; |
||
621 | |||
622 | /** |
||
623 | * @var Collection |
||
624 | * |
||
625 | * @ORM\ManyToMany(targetEntity="Oro\Bundle\ContactBundle\Entity\Group") |
||
626 | * @ORM\JoinTable(name="orocrm_contact_to_contact_grp", |
||
627 | * joinColumns={@ORM\JoinColumn(name="contact_id", referencedColumnName="id", onDelete="CASCADE")}, |
||
628 | * inverseJoinColumns={@ORM\JoinColumn(name="contact_group_id", referencedColumnName="id", onDelete="CASCADE")} |
||
629 | * ) |
||
630 | * @ConfigField( |
||
631 | * defaultValues={ |
||
632 | * "importexport"={ |
||
633 | * "order"=230, |
||
634 | * "short"=true |
||
635 | * }, |
||
636 | * "merge"={ |
||
637 | * "display"=true |
||
638 | * } |
||
639 | * } |
||
640 | * ) |
||
641 | */ |
||
642 | protected $groups; |
||
643 | |||
644 | /** |
||
645 | * @var Collection |
||
646 | * |
||
647 | * @ORM\ManyToMany(targetEntity="Oro\Bundle\AccountBundle\Entity\Account", mappedBy="contacts") |
||
648 | * @ORM\JoinTable(name="orocrm_account_to_contact") |
||
649 | * @ConfigField( |
||
650 | * defaultValues={ |
||
651 | * "importexport"={ |
||
652 | * "order"=240, |
||
653 | * "short"=true |
||
654 | * }, |
||
655 | * "merge"={ |
||
656 | * "display"=true |
||
657 | * } |
||
658 | * } |
||
659 | * ) |
||
660 | */ |
||
661 | protected $accounts; |
||
662 | |||
663 | /** |
||
664 | * @var User |
||
665 | * |
||
666 | * @ORM\ManyToOne(targetEntity="Oro\Bundle\UserBundle\Entity\User") |
||
667 | * @ORM\JoinColumn(name="created_by_user_id", referencedColumnName="id", onDelete="SET NULL") |
||
668 | * @ConfigField( |
||
669 | * defaultValues={ |
||
670 | * "importexport"={ |
||
671 | * "excluded"=true |
||
672 | * } |
||
673 | * } |
||
674 | * ) |
||
675 | */ |
||
676 | protected $createdBy; |
||
677 | |||
678 | /** |
||
679 | * @var User |
||
680 | * |
||
681 | * @ORM\ManyToOne(targetEntity="Oro\Bundle\UserBundle\Entity\User") |
||
682 | * @ORM\JoinColumn(name="updated_by_user_id", referencedColumnName="id", onDelete="SET NULL") |
||
683 | * @ConfigField( |
||
684 | * defaultValues={ |
||
685 | * "importexport"={ |
||
686 | * "excluded"=true |
||
687 | * } |
||
688 | * } |
||
689 | * ) |
||
690 | */ |
||
691 | protected $updatedBy; |
||
692 | |||
693 | /** |
||
694 | * @var \DateTime $created |
||
695 | * |
||
696 | * @ORM\Column(type="datetime") |
||
697 | * @Soap\ComplexType("dateTime", nillable=true) |
||
698 | * @ConfigField( |
||
699 | * defaultValues={ |
||
700 | * "entity"={ |
||
701 | * "label"="oro.ui.created_at" |
||
702 | * }, |
||
703 | * "importexport"={ |
||
704 | * "excluded"=true |
||
705 | * } |
||
706 | * } |
||
707 | * ) |
||
708 | */ |
||
709 | protected $createdAt; |
||
710 | |||
711 | /** |
||
712 | * @var \DateTime $updated |
||
713 | * |
||
714 | * @ORM\Column(type="datetime") |
||
715 | * @Soap\ComplexType("dateTime", nillable=true) |
||
716 | * @ConfigField( |
||
717 | * defaultValues={ |
||
718 | * "entity"={ |
||
719 | * "label"="oro.ui.updated_at" |
||
720 | * }, |
||
721 | * "importexport"={ |
||
722 | * "excluded"=true |
||
723 | * } |
||
724 | * } |
||
725 | * ) |
||
726 | */ |
||
727 | protected $updatedAt; |
||
728 | |||
729 | /** |
||
730 | * @var Organization |
||
731 | * |
||
732 | * @ORM\ManyToOne(targetEntity="Oro\Bundle\OrganizationBundle\Entity\Organization") |
||
733 | * @ORM\JoinColumn(name="organization_id", referencedColumnName="id", onDelete="SET NULL") |
||
734 | */ |
||
735 | protected $organization; |
||
736 | |||
737 | /** |
||
738 | * @var Account[]|Collection |
||
739 | * |
||
740 | * @ORM\OneToMany(targetEntity="Oro\Bundle\AccountBundle\Entity\Account", |
||
741 | * mappedBy="defaultContact", cascade={"persist"} |
||
742 | * ) |
||
743 | * @ConfigField( |
||
744 | * defaultValues={ |
||
745 | * "importexport"={ |
||
746 | * "order"=240 |
||
747 | * } |
||
748 | * } |
||
749 | * ) |
||
750 | */ |
||
751 | protected $defaultInAccounts; |
||
752 | |||
753 | public function __construct() |
||
763 | |||
764 | public function __clone() |
||
784 | |||
785 | /** |
||
786 | * Get entity class name. |
||
787 | * TODO: Remove this temporary solution for get 'view' route in twig after EntityConfigBundle is finished |
||
788 | * @return string |
||
789 | */ |
||
790 | public function getClass() |
||
794 | |||
795 | /** |
||
796 | * Get names of fields contain email addresses |
||
797 | * |
||
798 | * @return string[]|null |
||
799 | */ |
||
800 | public function getEmailFields() |
||
804 | |||
805 | /** |
||
806 | * @param User $assignedTo |
||
807 | * |
||
808 | * @return Contact |
||
809 | */ |
||
810 | public function setAssignedTo($assignedTo) |
||
816 | |||
817 | /** |
||
818 | * @return User |
||
819 | */ |
||
820 | public function getAssignedTo() |
||
824 | |||
825 | /** |
||
826 | * @param string $description |
||
827 | * |
||
828 | * @return Contact |
||
829 | */ |
||
830 | public function setDescription($description) |
||
836 | |||
837 | /** |
||
838 | * @return string |
||
839 | */ |
||
840 | public function getDescription() |
||
844 | |||
845 | /** |
||
846 | * @param Source $source |
||
847 | * |
||
848 | * @return Contact |
||
849 | */ |
||
850 | public function setSource($source) |
||
856 | |||
857 | /** |
||
858 | * @return Source |
||
859 | */ |
||
860 | public function getSource() |
||
864 | |||
865 | /** |
||
866 | * @param Method $method |
||
867 | * |
||
868 | * @return Contact |
||
869 | */ |
||
870 | public function setMethod($method) |
||
876 | |||
877 | /** |
||
878 | * @return Method |
||
879 | */ |
||
880 | public function getMethod() |
||
884 | |||
885 | /** |
||
886 | * @param User $owningUser |
||
887 | * |
||
888 | * @return Contact |
||
889 | */ |
||
890 | public function setOwner($owningUser) |
||
896 | |||
897 | /** |
||
898 | * @return User |
||
899 | */ |
||
900 | public function getOwner() |
||
904 | |||
905 | /** |
||
906 | * @param Contact $reportsTo |
||
907 | * |
||
908 | * @return Contact |
||
909 | */ |
||
910 | public function setReportsTo($reportsTo) |
||
916 | |||
917 | /** |
||
918 | * @return Contact |
||
919 | */ |
||
920 | public function getReportsTo() |
||
924 | |||
925 | /** |
||
926 | * @param string $jobTitle |
||
927 | * |
||
928 | * @return Contact |
||
929 | */ |
||
930 | public function setJobTitle($jobTitle) |
||
936 | |||
937 | /** |
||
938 | * @return string |
||
939 | */ |
||
940 | public function getJobTitle() |
||
944 | |||
945 | /** |
||
946 | * @param string $fax |
||
947 | * |
||
948 | * @return Contact |
||
949 | */ |
||
950 | public function setFax($fax) |
||
956 | |||
957 | /** |
||
958 | * @return string |
||
959 | */ |
||
960 | public function getFax() |
||
964 | |||
965 | /** |
||
966 | * @param string $skype |
||
967 | * |
||
968 | * @return Contact |
||
969 | */ |
||
970 | public function setSkype($skype) |
||
976 | |||
977 | /** |
||
978 | * @return string |
||
979 | */ |
||
980 | public function getSkype() |
||
984 | |||
985 | /** |
||
986 | * @param string $facebookUrl |
||
987 | * |
||
988 | * @return Contact |
||
989 | */ |
||
990 | public function setFacebook($facebookUrl) |
||
996 | |||
997 | /** |
||
998 | * @return string |
||
999 | */ |
||
1000 | public function getFacebook() |
||
1004 | |||
1005 | /** |
||
1006 | * @param string $googlePlusUrl |
||
1007 | * |
||
1008 | * @return Contact |
||
1009 | */ |
||
1010 | public function setGooglePlus($googlePlusUrl) |
||
1016 | |||
1017 | /** |
||
1018 | * @return string |
||
1019 | */ |
||
1020 | public function getGooglePlus() |
||
1024 | |||
1025 | /** |
||
1026 | * @param string $linkedInUrl |
||
1027 | * |
||
1028 | * @return Contact |
||
1029 | */ |
||
1030 | public function setLinkedIn($linkedInUrl) |
||
1036 | |||
1037 | /** |
||
1038 | * @return string |
||
1039 | */ |
||
1040 | public function getLinkedIn() |
||
1044 | |||
1045 | /** |
||
1046 | * @param string $twitterUrl |
||
1047 | * |
||
1048 | * @return Contact |
||
1049 | */ |
||
1050 | public function setTwitter($twitterUrl) |
||
1056 | |||
1057 | /** |
||
1058 | * @return string |
||
1059 | */ |
||
1060 | public function getTwitter() |
||
1064 | |||
1065 | /** |
||
1066 | * Set emails. |
||
1067 | * |
||
1068 | * This method could not be named setEmails because of bug CRM-253. |
||
1069 | * |
||
1070 | * @param Collection|ContactEmail[] $emails |
||
1071 | * |
||
1072 | * @return Contact |
||
1073 | */ |
||
1074 | public function resetEmails($emails) |
||
1084 | |||
1085 | /** |
||
1086 | * Add email |
||
1087 | * |
||
1088 | * @param ContactEmail $email |
||
1089 | * |
||
1090 | * @return Contact |
||
1091 | */ |
||
1092 | public function addEmail(ContactEmail $email) |
||
1106 | |||
1107 | /** |
||
1108 | * Remove email |
||
1109 | * |
||
1110 | * @param ContactEmail $email |
||
1111 | * |
||
1112 | * @return Contact |
||
1113 | */ |
||
1114 | public function removeEmail(ContactEmail $email) |
||
1122 | |||
1123 | /** |
||
1124 | * Get emails |
||
1125 | * |
||
1126 | * @return Collection|ContactEmail[] |
||
1127 | */ |
||
1128 | public function getEmails() |
||
1132 | |||
1133 | /** |
||
1134 | * {@inheritdoc} |
||
1135 | */ |
||
1136 | public function getEmail() |
||
1145 | |||
1146 | /** |
||
1147 | * @param ContactEmail $email |
||
1148 | * @return bool |
||
1149 | */ |
||
1150 | public function hasEmail(ContactEmail $email) |
||
1154 | |||
1155 | /** |
||
1156 | * Gets primary email if it's available. |
||
1157 | * |
||
1158 | * @return ContactEmail|null |
||
1159 | */ |
||
1160 | View Code Duplication | public function getPrimaryEmail() |
|
1173 | |||
1174 | /** |
||
1175 | * @param ContactEmail $email |
||
1176 | * @return Contact |
||
1177 | */ |
||
1178 | View Code Duplication | public function setPrimaryEmail(ContactEmail $email) |
|
1191 | |||
1192 | /** |
||
1193 | * Set phones. |
||
1194 | * |
||
1195 | * This method could not be named setPhones because of bug CRM-253. |
||
1196 | * |
||
1197 | * @param Collection|ContactPhone[] $phones |
||
1198 | * |
||
1199 | * @return Contact |
||
1200 | */ |
||
1201 | public function resetPhones($phones) |
||
1211 | |||
1212 | /** |
||
1213 | * Add phone |
||
1214 | * |
||
1215 | * @param ContactPhone $phone |
||
1216 | * |
||
1217 | * @return Contact |
||
1218 | */ |
||
1219 | public function addPhone(ContactPhone $phone) |
||
1233 | |||
1234 | /** |
||
1235 | * Remove phone |
||
1236 | * |
||
1237 | * @param ContactPhone $phone |
||
1238 | * |
||
1239 | * @return Contact |
||
1240 | */ |
||
1241 | public function removePhone(ContactPhone $phone) |
||
1249 | |||
1250 | /** |
||
1251 | * Get phones |
||
1252 | * |
||
1253 | * @return Collection|ContactPhone[] |
||
1254 | */ |
||
1255 | public function getPhones() |
||
1259 | |||
1260 | /** |
||
1261 | * @param ContactPhone $phone |
||
1262 | * @return bool |
||
1263 | */ |
||
1264 | public function hasPhone(ContactPhone $phone) |
||
1268 | |||
1269 | /** |
||
1270 | * Gets primary phone if it's available. |
||
1271 | * |
||
1272 | * @return ContactPhone|null |
||
1273 | */ |
||
1274 | View Code Duplication | public function getPrimaryPhone() |
|
1287 | |||
1288 | /** |
||
1289 | * @param ContactPhone $phone |
||
1290 | * @return Contact |
||
1291 | */ |
||
1292 | View Code Duplication | public function setPrimaryPhone(ContactPhone $phone) |
|
1305 | |||
1306 | /** |
||
1307 | * Add address |
||
1308 | * |
||
1309 | * @param AbstractAddress $address |
||
1310 | * |
||
1311 | * @return BasePerson |
||
1312 | */ |
||
1313 | public function addAddress(AbstractAddress $address) |
||
1328 | |||
1329 | /** |
||
1330 | * Gets primary address if it's available. |
||
1331 | * |
||
1332 | * @return ContactAddress|null |
||
1333 | */ |
||
1334 | View Code Duplication | public function getPrimaryAddress() |
|
1348 | |||
1349 | /** |
||
1350 | * @param ContactAddress $address |
||
1351 | * |
||
1352 | * @return Contact |
||
1353 | */ |
||
1354 | View Code Duplication | public function setPrimaryAddress(ContactAddress $address) |
|
1368 | |||
1369 | /** |
||
1370 | * Gets address type if it's available. |
||
1371 | * |
||
1372 | * @param ContactAddress $address |
||
1373 | * @param AddressType $addressType |
||
1374 | * |
||
1375 | * @return Contact |
||
1376 | */ |
||
1377 | View Code Duplication | public function setAddressType(ContactAddress $address, AddressType $addressType) |
|
1391 | |||
1392 | /** |
||
1393 | * Gets one address that has specified type. |
||
1394 | * |
||
1395 | * @param AddressType $type |
||
1396 | * |
||
1397 | * @return ContactAddress|null |
||
1398 | */ |
||
1399 | public function getAddressByType(AddressType $type) |
||
1403 | |||
1404 | /** |
||
1405 | * Gets one address that has specified type name. |
||
1406 | * |
||
1407 | * @param string $typeName |
||
1408 | * |
||
1409 | * @return ContactAddress|null |
||
1410 | */ |
||
1411 | public function getAddressByTypeName($typeName) |
||
1425 | |||
1426 | /** |
||
1427 | * Get group labels separated with comma. |
||
1428 | * |
||
1429 | * @return string |
||
1430 | */ |
||
1431 | public function getGroupLabelsAsString() |
||
1435 | |||
1436 | /** |
||
1437 | * Get list of group labels |
||
1438 | * |
||
1439 | * @return array |
||
1440 | */ |
||
1441 | public function getGroupLabels() |
||
1452 | |||
1453 | /** |
||
1454 | * Gets the groups related to contact |
||
1455 | * |
||
1456 | * @return Group[]|Collection |
||
1457 | */ |
||
1458 | public function getGroups() |
||
1462 | |||
1463 | /** |
||
1464 | * Add specified group |
||
1465 | * |
||
1466 | * @param Group $group |
||
1467 | * |
||
1468 | * @return Contact |
||
1469 | */ |
||
1470 | public function addGroup(Group $group) |
||
1478 | |||
1479 | /** |
||
1480 | * Remove specified group |
||
1481 | * |
||
1482 | * @param Group $group |
||
1483 | * |
||
1484 | * @return Contact |
||
1485 | */ |
||
1486 | public function removeGroup(Group $group) |
||
1494 | |||
1495 | /** |
||
1496 | * Get accounts collection |
||
1497 | * |
||
1498 | * @return Collection|Account[] |
||
1499 | */ |
||
1500 | public function getAccounts() |
||
1504 | |||
1505 | /** |
||
1506 | * Add specified account |
||
1507 | * |
||
1508 | * @param Account $account |
||
1509 | * |
||
1510 | * @return Contact |
||
1511 | */ |
||
1512 | public function addAccount(Account $account) |
||
1521 | |||
1522 | /** |
||
1523 | * Remove specified account |
||
1524 | * |
||
1525 | * @param Account $account |
||
1526 | * |
||
1527 | * @return Contact |
||
1528 | */ |
||
1529 | public function removeAccount(Account $account) |
||
1538 | |||
1539 | /** |
||
1540 | * @return bool |
||
1541 | */ |
||
1542 | public function hasAccounts() |
||
1546 | |||
1547 | /** |
||
1548 | * @param \Oro\Bundle\UserBundle\Entity\User $createdBy |
||
1549 | * |
||
1550 | * @return Contact |
||
1551 | */ |
||
1552 | public function setCreatedBy($createdBy) |
||
1558 | |||
1559 | /** |
||
1560 | * @return \Oro\Bundle\UserBundle\Entity\User |
||
1561 | */ |
||
1562 | public function getCreatedBy() |
||
1566 | |||
1567 | /** |
||
1568 | * @param \Oro\Bundle\UserBundle\Entity\User $updatedBy |
||
1569 | * |
||
1570 | * @return Contact |
||
1571 | */ |
||
1572 | public function setUpdatedBy($updatedBy) |
||
1578 | |||
1579 | /** |
||
1580 | * @return \Oro\Bundle\UserBundle\Entity\User |
||
1581 | */ |
||
1582 | public function getUpdatedBy() |
||
1586 | |||
1587 | /** |
||
1588 | * @return string |
||
1589 | */ |
||
1590 | public function __toString() |
||
1601 | |||
1602 | /** |
||
1603 | * Set organization |
||
1604 | * |
||
1605 | * @param Organization $organization |
||
1606 | * @return Contact |
||
1607 | */ |
||
1608 | public function setOrganization(Organization $organization = null) |
||
1614 | |||
1615 | /** |
||
1616 | * Get organization |
||
1617 | * |
||
1618 | * @return Organization |
||
1619 | */ |
||
1620 | public function getOrganization() |
||
1624 | |||
1625 | /** |
||
1626 | * @param Account $account |
||
1627 | * |
||
1628 | * @return $this |
||
1629 | */ |
||
1630 | View Code Duplication | public function addDefaultInAccount(Account $account) |
|
1639 | |||
1640 | /** |
||
1641 | * @param Account $account |
||
1642 | * |
||
1643 | * @return $this |
||
1644 | */ |
||
1645 | View Code Duplication | public function removeDefaultInAccount(Account $account) |
|
1654 | |||
1655 | /** |
||
1656 | * @return Account[]|Collection |
||
1657 | */ |
||
1658 | public function getDefaultInAccounts() |
||
1662 | } |
||
1663 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.