Complex classes like Person 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 Person, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
12 | class Person extends BaseType |
||
13 | { |
||
14 | /** |
||
15 | * An additional name for a Person, can be used for a middle name. |
||
16 | * |
||
17 | * @param string|string[] $additionalName |
||
18 | * |
||
19 | * @return static |
||
20 | * |
||
21 | * @see http://schema.org/additionalName |
||
22 | */ |
||
23 | public function additionalName($additionalName) |
||
27 | |||
28 | /** |
||
29 | * Physical address of the item. |
||
30 | * |
||
31 | * @param PostalAddress|PostalAddress[]|string|string[] $address |
||
32 | * |
||
33 | * @return static |
||
34 | * |
||
35 | * @see http://schema.org/address |
||
36 | */ |
||
37 | public function address($address) |
||
41 | |||
42 | /** |
||
43 | * An organization that this person is affiliated with. For example, a |
||
44 | * school/university, a club, or a team. |
||
45 | * |
||
46 | * @param Organization|Organization[] $affiliation |
||
47 | * |
||
48 | * @return static |
||
49 | * |
||
50 | * @see http://schema.org/affiliation |
||
51 | */ |
||
52 | public function affiliation($affiliation) |
||
56 | |||
57 | /** |
||
58 | * An organization that the person is an alumni of. |
||
59 | * |
||
60 | * @param EducationalOrganization|EducationalOrganization[] $alumniOf |
||
61 | * |
||
62 | * @return static |
||
63 | * |
||
64 | * @see http://schema.org/alumniOf |
||
65 | */ |
||
66 | public function alumniOf($alumniOf) |
||
70 | |||
71 | /** |
||
72 | * An award won by or for this item. |
||
73 | * |
||
74 | * @param string|string[] $award |
||
75 | * |
||
76 | * @return static |
||
77 | * |
||
78 | * @see http://schema.org/award |
||
79 | */ |
||
80 | public function award($award) |
||
84 | |||
85 | /** |
||
86 | * Awards won by or for this item. |
||
87 | * |
||
88 | * @param string|string[] $awards |
||
89 | * |
||
90 | * @return static |
||
91 | * |
||
92 | * @see http://schema.org/awards |
||
93 | */ |
||
94 | public function awards($awards) |
||
98 | |||
99 | /** |
||
100 | * Date of birth. |
||
101 | * |
||
102 | * @param \DateTimeInterface|\DateTimeInterface[] $birthDate |
||
103 | * |
||
104 | * @return static |
||
105 | * |
||
106 | * @see http://schema.org/birthDate |
||
107 | */ |
||
108 | public function birthDate($birthDate) |
||
112 | |||
113 | /** |
||
114 | * The place where the person was born. |
||
115 | * |
||
116 | * @param Place|Place[] $birthPlace |
||
117 | * |
||
118 | * @return static |
||
119 | * |
||
120 | * @see http://schema.org/birthPlace |
||
121 | */ |
||
122 | public function birthPlace($birthPlace) |
||
126 | |||
127 | /** |
||
128 | * The brand(s) associated with a product or service, or the brand(s) |
||
129 | * maintained by an organization or business person. |
||
130 | * |
||
131 | * @param Brand|Brand[]|Organization|Organization[] $brand |
||
132 | * |
||
133 | * @return static |
||
134 | * |
||
135 | * @see http://schema.org/brand |
||
136 | */ |
||
137 | public function brand($brand) |
||
141 | |||
142 | /** |
||
143 | * A child of the person. |
||
144 | * |
||
145 | * @param Person|Person[] $children |
||
146 | * |
||
147 | * @return static |
||
148 | * |
||
149 | * @see http://schema.org/children |
||
150 | */ |
||
151 | public function children($children) |
||
155 | |||
156 | /** |
||
157 | * A colleague of the person. |
||
158 | * |
||
159 | * @param Person|Person[]|string|string[] $colleague |
||
160 | * |
||
161 | * @return static |
||
162 | * |
||
163 | * @see http://schema.org/colleague |
||
164 | */ |
||
165 | public function colleague($colleague) |
||
169 | |||
170 | /** |
||
171 | * A colleague of the person. |
||
172 | * |
||
173 | * @param Person|Person[] $colleagues |
||
174 | * |
||
175 | * @return static |
||
176 | * |
||
177 | * @see http://schema.org/colleagues |
||
178 | */ |
||
179 | public function colleagues($colleagues) |
||
183 | |||
184 | /** |
||
185 | * A contact point for a person or organization. |
||
186 | * |
||
187 | * @param ContactPoint|ContactPoint[] $contactPoint |
||
188 | * |
||
189 | * @return static |
||
190 | * |
||
191 | * @see http://schema.org/contactPoint |
||
192 | */ |
||
193 | public function contactPoint($contactPoint) |
||
197 | |||
198 | /** |
||
199 | * A contact point for a person or organization. |
||
200 | * |
||
201 | * @param ContactPoint|ContactPoint[] $contactPoints |
||
202 | * |
||
203 | * @return static |
||
204 | * |
||
205 | * @see http://schema.org/contactPoints |
||
206 | */ |
||
207 | public function contactPoints($contactPoints) |
||
211 | |||
212 | /** |
||
213 | * Date of death. |
||
214 | * |
||
215 | * @param \DateTimeInterface|\DateTimeInterface[] $deathDate |
||
216 | * |
||
217 | * @return static |
||
218 | * |
||
219 | * @see http://schema.org/deathDate |
||
220 | */ |
||
221 | public function deathDate($deathDate) |
||
225 | |||
226 | /** |
||
227 | * The place where the person died. |
||
228 | * |
||
229 | * @param Place|Place[] $deathPlace |
||
230 | * |
||
231 | * @return static |
||
232 | * |
||
233 | * @see http://schema.org/deathPlace |
||
234 | */ |
||
235 | public function deathPlace($deathPlace) |
||
239 | |||
240 | /** |
||
241 | * The Dun & Bradstreet DUNS number for identifying an organization or |
||
242 | * business person. |
||
243 | * |
||
244 | * @param string|string[] $duns |
||
245 | * |
||
246 | * @return static |
||
247 | * |
||
248 | * @see http://schema.org/duns |
||
249 | */ |
||
250 | public function duns($duns) |
||
254 | |||
255 | /** |
||
256 | * Email address. |
||
257 | * |
||
258 | * @param string|string[] $email |
||
259 | * |
||
260 | * @return static |
||
261 | * |
||
262 | * @see http://schema.org/email |
||
263 | */ |
||
264 | public function email($email) |
||
268 | |||
269 | /** |
||
270 | * Family name. In the U.S., the last name of an Person. This can be used |
||
271 | * along with givenName instead of the name property. |
||
272 | * |
||
273 | * @param string|string[] $familyName |
||
274 | * |
||
275 | * @return static |
||
276 | * |
||
277 | * @see http://schema.org/familyName |
||
278 | */ |
||
279 | public function familyName($familyName) |
||
283 | |||
284 | /** |
||
285 | * The fax number. |
||
286 | * |
||
287 | * @param string|string[] $faxNumber |
||
288 | * |
||
289 | * @return static |
||
290 | * |
||
291 | * @see http://schema.org/faxNumber |
||
292 | */ |
||
293 | public function faxNumber($faxNumber) |
||
297 | |||
298 | /** |
||
299 | * The most generic uni-directional social relation. |
||
300 | * |
||
301 | * @param Person|Person[] $follows |
||
302 | * |
||
303 | * @return static |
||
304 | * |
||
305 | * @see http://schema.org/follows |
||
306 | */ |
||
307 | public function follows($follows) |
||
311 | |||
312 | /** |
||
313 | * A person or organization that supports (sponsors) something through some |
||
314 | * kind of financial contribution. |
||
315 | * |
||
316 | * @param Organization|Organization[]|Person|Person[] $funder |
||
317 | * |
||
318 | * @return static |
||
319 | * |
||
320 | * @see http://schema.org/funder |
||
321 | */ |
||
322 | public function funder($funder) |
||
326 | |||
327 | /** |
||
328 | * Gender of the person. While http://schema.org/Male and |
||
329 | * http://schema.org/Female may be used, text strings are also acceptable |
||
330 | * for people who do not identify as a binary gender. |
||
331 | * |
||
332 | * @param GenderType|GenderType[]|string|string[] $gender |
||
333 | * |
||
334 | * @return static |
||
335 | * |
||
336 | * @see http://schema.org/gender |
||
337 | */ |
||
338 | public function gender($gender) |
||
342 | |||
343 | /** |
||
344 | * Given name. In the U.S., the first name of a Person. This can be used |
||
345 | * along with familyName instead of the name property. |
||
346 | * |
||
347 | * @param string|string[] $givenName |
||
348 | * |
||
349 | * @return static |
||
350 | * |
||
351 | * @see http://schema.org/givenName |
||
352 | */ |
||
353 | public function givenName($givenName) |
||
357 | |||
358 | /** |
||
359 | * The [Global Location Number](http://www.gs1.org/gln) (GLN, sometimes also |
||
360 | * referred to as International Location Number or ILN) of the respective |
||
361 | * organization, person, or place. The GLN is a 13-digit number used to |
||
362 | * identify parties and physical locations. |
||
363 | * |
||
364 | * @param string|string[] $globalLocationNumber |
||
365 | * |
||
366 | * @return static |
||
367 | * |
||
368 | * @see http://schema.org/globalLocationNumber |
||
369 | */ |
||
370 | public function globalLocationNumber($globalLocationNumber) |
||
374 | |||
375 | /** |
||
376 | * The Person's occupation. For past professions, use Role for expressing |
||
377 | * dates. |
||
378 | * |
||
379 | * @param Occupation|Occupation[] $hasOccupation |
||
380 | * |
||
381 | * @return static |
||
382 | * |
||
383 | * @see http://schema.org/hasOccupation |
||
384 | */ |
||
385 | public function hasOccupation($hasOccupation) |
||
389 | |||
390 | /** |
||
391 | * Indicates an OfferCatalog listing for this Organization, Person, or |
||
392 | * Service. |
||
393 | * |
||
394 | * @param OfferCatalog|OfferCatalog[] $hasOfferCatalog |
||
395 | * |
||
396 | * @return static |
||
397 | * |
||
398 | * @see http://schema.org/hasOfferCatalog |
||
399 | */ |
||
400 | public function hasOfferCatalog($hasOfferCatalog) |
||
404 | |||
405 | /** |
||
406 | * Points-of-Sales operated by the organization or person. |
||
407 | * |
||
408 | * @param Place|Place[] $hasPOS |
||
409 | * |
||
410 | * @return static |
||
411 | * |
||
412 | * @see http://schema.org/hasPOS |
||
413 | */ |
||
414 | public function hasPOS($hasPOS) |
||
418 | |||
419 | /** |
||
420 | * The height of the item. |
||
421 | * |
||
422 | * @param Distance|Distance[]|QuantitativeValue|QuantitativeValue[] $height |
||
423 | * |
||
424 | * @return static |
||
425 | * |
||
426 | * @see http://schema.org/height |
||
427 | */ |
||
428 | public function height($height) |
||
432 | |||
433 | /** |
||
434 | * A contact location for a person's residence. |
||
435 | * |
||
436 | * @param ContactPoint|ContactPoint[]|Place|Place[] $homeLocation |
||
437 | * |
||
438 | * @return static |
||
439 | * |
||
440 | * @see http://schema.org/homeLocation |
||
441 | */ |
||
442 | public function homeLocation($homeLocation) |
||
446 | |||
447 | /** |
||
448 | * An honorific prefix preceding a Person's name such as Dr/Mrs/Mr. |
||
449 | * |
||
450 | * @param string|string[] $honorificPrefix |
||
451 | * |
||
452 | * @return static |
||
453 | * |
||
454 | * @see http://schema.org/honorificPrefix |
||
455 | */ |
||
456 | public function honorificPrefix($honorificPrefix) |
||
460 | |||
461 | /** |
||
462 | * An honorific suffix preceding a Person's name such as M.D. /PhD/MSCSW. |
||
463 | * |
||
464 | * @param string|string[] $honorificSuffix |
||
465 | * |
||
466 | * @return static |
||
467 | * |
||
468 | * @see http://schema.org/honorificSuffix |
||
469 | */ |
||
470 | public function honorificSuffix($honorificSuffix) |
||
474 | |||
475 | /** |
||
476 | * The International Standard of Industrial Classification of All Economic |
||
477 | * Activities (ISIC), Revision 4 code for a particular organization, |
||
478 | * business person, or place. |
||
479 | * |
||
480 | * @param string|string[] $isicV4 |
||
481 | * |
||
482 | * @return static |
||
483 | * |
||
484 | * @see http://schema.org/isicV4 |
||
485 | */ |
||
486 | public function isicV4($isicV4) |
||
490 | |||
491 | /** |
||
492 | * The job title of the person (for example, Financial Manager). |
||
493 | * |
||
494 | * @param string|string[] $jobTitle |
||
495 | * |
||
496 | * @return static |
||
497 | * |
||
498 | * @see http://schema.org/jobTitle |
||
499 | */ |
||
500 | public function jobTitle($jobTitle) |
||
504 | |||
505 | /** |
||
506 | * The most generic bi-directional social/work relation. |
||
507 | * |
||
508 | * @param Person|Person[] $knows |
||
509 | * |
||
510 | * @return static |
||
511 | * |
||
512 | * @see http://schema.org/knows |
||
513 | */ |
||
514 | public function knows($knows) |
||
518 | |||
519 | /** |
||
520 | * A pointer to products or services offered by the organization or person. |
||
521 | * |
||
522 | * @param Offer|Offer[] $makesOffer |
||
523 | * |
||
524 | * @return static |
||
525 | * |
||
526 | * @see http://schema.org/makesOffer |
||
527 | */ |
||
528 | public function makesOffer($makesOffer) |
||
532 | |||
533 | /** |
||
534 | * An Organization (or ProgramMembership) to which this Person or |
||
535 | * Organization belongs. |
||
536 | * |
||
537 | * @param Organization|Organization[]|ProgramMembership|ProgramMembership[] $memberOf |
||
538 | * |
||
539 | * @return static |
||
540 | * |
||
541 | * @see http://schema.org/memberOf |
||
542 | */ |
||
543 | public function memberOf($memberOf) |
||
547 | |||
548 | /** |
||
549 | * The North American Industry Classification System (NAICS) code for a |
||
550 | * particular organization or business person. |
||
551 | * |
||
552 | * @param string|string[] $naics |
||
553 | * |
||
554 | * @return static |
||
555 | * |
||
556 | * @see http://schema.org/naics |
||
557 | */ |
||
558 | public function naics($naics) |
||
562 | |||
563 | /** |
||
564 | * Nationality of the person. |
||
565 | * |
||
566 | * @param Country|Country[] $nationality |
||
567 | * |
||
568 | * @return static |
||
569 | * |
||
570 | * @see http://schema.org/nationality |
||
571 | */ |
||
572 | public function nationality($nationality) |
||
576 | |||
577 | /** |
||
578 | * The total financial value of the person as calculated by subtracting |
||
579 | * assets from liabilities. |
||
580 | * |
||
581 | * @param MonetaryAmount|MonetaryAmount[]|PriceSpecification|PriceSpecification[] $netWorth |
||
582 | * |
||
583 | * @return static |
||
584 | * |
||
585 | * @see http://schema.org/netWorth |
||
586 | */ |
||
587 | public function netWorth($netWorth) |
||
591 | |||
592 | /** |
||
593 | * Products owned by the organization or person. |
||
594 | * |
||
595 | * @param OwnershipInfo|OwnershipInfo[]|Product|Product[] $owns |
||
596 | * |
||
597 | * @return static |
||
598 | * |
||
599 | * @see http://schema.org/owns |
||
600 | */ |
||
601 | public function owns($owns) |
||
605 | |||
606 | /** |
||
607 | * A parent of this person. |
||
608 | * |
||
609 | * @param Person|Person[] $parent |
||
610 | * |
||
611 | * @return static |
||
612 | * |
||
613 | * @see http://schema.org/parent |
||
614 | */ |
||
615 | public function parent($parent) |
||
619 | |||
620 | /** |
||
621 | * A parents of the person. |
||
622 | * |
||
623 | * @param Person|Person[] $parents |
||
624 | * |
||
625 | * @return static |
||
626 | * |
||
627 | * @see http://schema.org/parents |
||
628 | */ |
||
629 | public function parents($parents) |
||
633 | |||
634 | /** |
||
635 | * Event that this person is a performer or participant in. |
||
636 | * |
||
637 | * @param Event|Event[] $performerIn |
||
638 | * |
||
639 | * @return static |
||
640 | * |
||
641 | * @see http://schema.org/performerIn |
||
642 | */ |
||
643 | public function performerIn($performerIn) |
||
647 | |||
648 | /** |
||
649 | * The publishingPrinciples property indicates (typically via [[URL]]) a |
||
650 | * document describing the editorial principles of an [[Organization]] (or |
||
651 | * individual e.g. a [[Person]] writing a blog) that relate to their |
||
652 | * activities as a publisher, e.g. ethics or diversity policies. When |
||
653 | * applied to a [[CreativeWork]] (e.g. [[NewsArticle]]) the principles are |
||
654 | * those of the party primarily responsible for the creation of the |
||
655 | * [[CreativeWork]]. |
||
656 | * |
||
657 | * While such policies are most typically expressed in natural language, |
||
658 | * sometimes related information (e.g. indicating a [[funder]]) can be |
||
659 | * expressed using schema.org terminology. |
||
660 | * |
||
661 | * @param CreativeWork|CreativeWork[]|string|string[] $publishingPrinciples |
||
662 | * |
||
663 | * @return static |
||
664 | * |
||
665 | * @see http://schema.org/publishingPrinciples |
||
666 | */ |
||
667 | public function publishingPrinciples($publishingPrinciples) |
||
671 | |||
672 | /** |
||
673 | * The most generic familial relation. |
||
674 | * |
||
675 | * @param Person|Person[] $relatedTo |
||
676 | * |
||
677 | * @return static |
||
678 | * |
||
679 | * @see http://schema.org/relatedTo |
||
680 | */ |
||
681 | public function relatedTo($relatedTo) |
||
685 | |||
686 | /** |
||
687 | * A pointer to products or services sought by the organization or person |
||
688 | * (demand). |
||
689 | * |
||
690 | * @param Demand|Demand[] $seeks |
||
691 | * |
||
692 | * @return static |
||
693 | * |
||
694 | * @see http://schema.org/seeks |
||
695 | */ |
||
696 | public function seeks($seeks) |
||
700 | |||
701 | /** |
||
702 | * A sibling of the person. |
||
703 | * |
||
704 | * @param Person|Person[] $sibling |
||
705 | * |
||
706 | * @return static |
||
707 | * |
||
708 | * @see http://schema.org/sibling |
||
709 | */ |
||
710 | public function sibling($sibling) |
||
714 | |||
715 | /** |
||
716 | * A sibling of the person. |
||
717 | * |
||
718 | * @param Person|Person[] $siblings |
||
719 | * |
||
720 | * @return static |
||
721 | * |
||
722 | * @see http://schema.org/siblings |
||
723 | */ |
||
724 | public function siblings($siblings) |
||
728 | |||
729 | /** |
||
730 | * A person or organization that supports a thing through a pledge, promise, |
||
731 | * or financial contribution. e.g. a sponsor of a Medical Study or a |
||
732 | * corporate sponsor of an event. |
||
733 | * |
||
734 | * @param Organization|Organization[]|Person|Person[] $sponsor |
||
735 | * |
||
736 | * @return static |
||
737 | * |
||
738 | * @see http://schema.org/sponsor |
||
739 | */ |
||
740 | public function sponsor($sponsor) |
||
744 | |||
745 | /** |
||
746 | * The person's spouse. |
||
747 | * |
||
748 | * @param Person|Person[] $spouse |
||
749 | * |
||
750 | * @return static |
||
751 | * |
||
752 | * @see http://schema.org/spouse |
||
753 | */ |
||
754 | public function spouse($spouse) |
||
758 | |||
759 | /** |
||
760 | * The Tax / Fiscal ID of the organization or person, e.g. the TIN in the US |
||
761 | * or the CIF/NIF in Spain. |
||
762 | * |
||
763 | * @param string|string[] $taxID |
||
764 | * |
||
765 | * @return static |
||
766 | * |
||
767 | * @see http://schema.org/taxID |
||
768 | */ |
||
769 | public function taxID($taxID) |
||
773 | |||
774 | /** |
||
775 | * The telephone number. |
||
776 | * |
||
777 | * @param string|string[] $telephone |
||
778 | * |
||
779 | * @return static |
||
780 | * |
||
781 | * @see http://schema.org/telephone |
||
782 | */ |
||
783 | public function telephone($telephone) |
||
787 | |||
788 | /** |
||
789 | * The Value-added Tax ID of the organization or person. |
||
790 | * |
||
791 | * @param string|string[] $vatID |
||
792 | * |
||
793 | * @return static |
||
794 | * |
||
795 | * @see http://schema.org/vatID |
||
796 | */ |
||
797 | public function vatID($vatID) |
||
801 | |||
802 | /** |
||
803 | * The weight of the product or person. |
||
804 | * |
||
805 | * @param QuantitativeValue|QuantitativeValue[] $weight |
||
806 | * |
||
807 | * @return static |
||
808 | * |
||
809 | * @see http://schema.org/weight |
||
810 | */ |
||
811 | public function weight($weight) |
||
815 | |||
816 | /** |
||
817 | * A contact location for a person's place of work. |
||
818 | * |
||
819 | * @param ContactPoint|ContactPoint[]|Place|Place[] $workLocation |
||
820 | * |
||
821 | * @return static |
||
822 | * |
||
823 | * @see http://schema.org/workLocation |
||
824 | */ |
||
825 | public function workLocation($workLocation) |
||
829 | |||
830 | /** |
||
831 | * Organizations that the person works for. |
||
832 | * |
||
833 | * @param Organization|Organization[] $worksFor |
||
834 | * |
||
835 | * @return static |
||
836 | * |
||
837 | * @see http://schema.org/worksFor |
||
838 | */ |
||
839 | public function worksFor($worksFor) |
||
843 | |||
844 | } |
||
845 |