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 |
||
10 | class Person extends Thing |
||
11 | { |
||
12 | /** |
||
13 | * An additional name for a Person, can be used for a middle name. |
||
14 | * |
||
15 | * @param string|string[] $additionalName |
||
16 | * |
||
17 | * @return static |
||
18 | * |
||
19 | * @see http://schema.org/additionalName |
||
20 | */ |
||
21 | public function additionalName($additionalName) |
||
25 | |||
26 | /** |
||
27 | * Physical address of the item. |
||
28 | * |
||
29 | * @param PostalAddress|PostalAddress[]|string|string[] $address |
||
30 | * |
||
31 | * @return static |
||
32 | * |
||
33 | * @see http://schema.org/address |
||
34 | */ |
||
35 | public function address($address) |
||
39 | |||
40 | /** |
||
41 | * An organization that this person is affiliated with. For example, a |
||
42 | * school/university, a club, or a team. |
||
43 | * |
||
44 | * @param Organization|Organization[] $affiliation |
||
45 | * |
||
46 | * @return static |
||
47 | * |
||
48 | * @see http://schema.org/affiliation |
||
49 | */ |
||
50 | public function affiliation($affiliation) |
||
54 | |||
55 | /** |
||
56 | * An organization that the person is an alumni of. |
||
57 | * |
||
58 | * @param EducationalOrganization|EducationalOrganization[] $alumniOf |
||
59 | * |
||
60 | * @return static |
||
61 | * |
||
62 | * @see http://schema.org/alumniOf |
||
63 | */ |
||
64 | public function alumniOf($alumniOf) |
||
68 | |||
69 | /** |
||
70 | * An award won by or for this item. |
||
71 | * |
||
72 | * @param string|string[] $award |
||
73 | * |
||
74 | * @return static |
||
75 | * |
||
76 | * @see http://schema.org/award |
||
77 | */ |
||
78 | public function award($award) |
||
82 | |||
83 | /** |
||
84 | * Awards won by or for this item. |
||
85 | * |
||
86 | * @param string|string[] $awards |
||
87 | * |
||
88 | * @return static |
||
89 | * |
||
90 | * @see http://schema.org/awards |
||
91 | */ |
||
92 | public function awards($awards) |
||
96 | |||
97 | /** |
||
98 | * Date of birth. |
||
99 | * |
||
100 | * @param \DateTimeInterface|\DateTimeInterface[] $birthDate |
||
101 | * |
||
102 | * @return static |
||
103 | * |
||
104 | * @see http://schema.org/birthDate |
||
105 | */ |
||
106 | public function birthDate($birthDate) |
||
110 | |||
111 | /** |
||
112 | * The place where the person was born. |
||
113 | * |
||
114 | * @param Place|Place[] $birthPlace |
||
115 | * |
||
116 | * @return static |
||
117 | * |
||
118 | * @see http://schema.org/birthPlace |
||
119 | */ |
||
120 | public function birthPlace($birthPlace) |
||
124 | |||
125 | /** |
||
126 | * The brand(s) associated with a product or service, or the brand(s) |
||
127 | * maintained by an organization or business person. |
||
128 | * |
||
129 | * @param Brand|Brand[]|Organization|Organization[] $brand |
||
130 | * |
||
131 | * @return static |
||
132 | * |
||
133 | * @see http://schema.org/brand |
||
134 | */ |
||
135 | public function brand($brand) |
||
139 | |||
140 | /** |
||
141 | * A child of the person. |
||
142 | * |
||
143 | * @param Person|Person[] $children |
||
144 | * |
||
145 | * @return static |
||
146 | * |
||
147 | * @see http://schema.org/children |
||
148 | */ |
||
149 | public function children($children) |
||
153 | |||
154 | /** |
||
155 | * A colleague of the person. |
||
156 | * |
||
157 | * @param Person|Person[]|string|string[] $colleague |
||
158 | * |
||
159 | * @return static |
||
160 | * |
||
161 | * @see http://schema.org/colleague |
||
162 | */ |
||
163 | public function colleague($colleague) |
||
167 | |||
168 | /** |
||
169 | * A colleague of the person. |
||
170 | * |
||
171 | * @param Person|Person[] $colleagues |
||
172 | * |
||
173 | * @return static |
||
174 | * |
||
175 | * @see http://schema.org/colleagues |
||
176 | */ |
||
177 | public function colleagues($colleagues) |
||
181 | |||
182 | /** |
||
183 | * A contact point for a person or organization. |
||
184 | * |
||
185 | * @param ContactPoint|ContactPoint[] $contactPoint |
||
186 | * |
||
187 | * @return static |
||
188 | * |
||
189 | * @see http://schema.org/contactPoint |
||
190 | */ |
||
191 | public function contactPoint($contactPoint) |
||
195 | |||
196 | /** |
||
197 | * A contact point for a person or organization. |
||
198 | * |
||
199 | * @param ContactPoint|ContactPoint[] $contactPoints |
||
200 | * |
||
201 | * @return static |
||
202 | * |
||
203 | * @see http://schema.org/contactPoints |
||
204 | */ |
||
205 | public function contactPoints($contactPoints) |
||
209 | |||
210 | /** |
||
211 | * Date of death. |
||
212 | * |
||
213 | * @param \DateTimeInterface|\DateTimeInterface[] $deathDate |
||
214 | * |
||
215 | * @return static |
||
216 | * |
||
217 | * @see http://schema.org/deathDate |
||
218 | */ |
||
219 | public function deathDate($deathDate) |
||
223 | |||
224 | /** |
||
225 | * The place where the person died. |
||
226 | * |
||
227 | * @param Place|Place[] $deathPlace |
||
228 | * |
||
229 | * @return static |
||
230 | * |
||
231 | * @see http://schema.org/deathPlace |
||
232 | */ |
||
233 | public function deathPlace($deathPlace) |
||
237 | |||
238 | /** |
||
239 | * The Dun & Bradstreet DUNS number for identifying an organization or |
||
240 | * business person. |
||
241 | * |
||
242 | * @param string|string[] $duns |
||
243 | * |
||
244 | * @return static |
||
245 | * |
||
246 | * @see http://schema.org/duns |
||
247 | */ |
||
248 | public function duns($duns) |
||
252 | |||
253 | /** |
||
254 | * Email address. |
||
255 | * |
||
256 | * @param string|string[] $email |
||
257 | * |
||
258 | * @return static |
||
259 | * |
||
260 | * @see http://schema.org/email |
||
261 | */ |
||
262 | public function email($email) |
||
266 | |||
267 | /** |
||
268 | * Family name. In the U.S., the last name of an Person. This can be used |
||
269 | * along with givenName instead of the name property. |
||
270 | * |
||
271 | * @param string|string[] $familyName |
||
272 | * |
||
273 | * @return static |
||
274 | * |
||
275 | * @see http://schema.org/familyName |
||
276 | */ |
||
277 | public function familyName($familyName) |
||
281 | |||
282 | /** |
||
283 | * The fax number. |
||
284 | * |
||
285 | * @param string|string[] $faxNumber |
||
286 | * |
||
287 | * @return static |
||
288 | * |
||
289 | * @see http://schema.org/faxNumber |
||
290 | */ |
||
291 | public function faxNumber($faxNumber) |
||
295 | |||
296 | /** |
||
297 | * The most generic uni-directional social relation. |
||
298 | * |
||
299 | * @param Person|Person[] $follows |
||
300 | * |
||
301 | * @return static |
||
302 | * |
||
303 | * @see http://schema.org/follows |
||
304 | */ |
||
305 | public function follows($follows) |
||
309 | |||
310 | /** |
||
311 | * A person or organization that supports (sponsors) something through some |
||
312 | * kind of financial contribution. |
||
313 | * |
||
314 | * @param Organization|Organization[]|Person|Person[] $funder |
||
315 | * |
||
316 | * @return static |
||
317 | * |
||
318 | * @see http://schema.org/funder |
||
319 | */ |
||
320 | public function funder($funder) |
||
324 | |||
325 | /** |
||
326 | * Gender of the person. While http://schema.org/Male and |
||
327 | * http://schema.org/Female may be used, text strings are also acceptable |
||
328 | * for people who do not identify as a binary gender. |
||
329 | * |
||
330 | * @param GenderType|GenderType[]|string|string[] $gender |
||
331 | * |
||
332 | * @return static |
||
333 | * |
||
334 | * @see http://schema.org/gender |
||
335 | */ |
||
336 | public function gender($gender) |
||
340 | |||
341 | /** |
||
342 | * Given name. In the U.S., the first name of a Person. This can be used |
||
343 | * along with familyName instead of the name property. |
||
344 | * |
||
345 | * @param string|string[] $givenName |
||
346 | * |
||
347 | * @return static |
||
348 | * |
||
349 | * @see http://schema.org/givenName |
||
350 | */ |
||
351 | public function givenName($givenName) |
||
355 | |||
356 | /** |
||
357 | * The [Global Location Number](http://www.gs1.org/gln) (GLN, sometimes also |
||
358 | * referred to as International Location Number or ILN) of the respective |
||
359 | * organization, person, or place. The GLN is a 13-digit number used to |
||
360 | * identify parties and physical locations. |
||
361 | * |
||
362 | * @param string|string[] $globalLocationNumber |
||
363 | * |
||
364 | * @return static |
||
365 | * |
||
366 | * @see http://schema.org/globalLocationNumber |
||
367 | */ |
||
368 | public function globalLocationNumber($globalLocationNumber) |
||
372 | |||
373 | /** |
||
374 | * Indicates an OfferCatalog listing for this Organization, Person, or |
||
375 | * Service. |
||
376 | * |
||
377 | * @param OfferCatalog|OfferCatalog[] $hasOfferCatalog |
||
378 | * |
||
379 | * @return static |
||
380 | * |
||
381 | * @see http://schema.org/hasOfferCatalog |
||
382 | */ |
||
383 | public function hasOfferCatalog($hasOfferCatalog) |
||
387 | |||
388 | /** |
||
389 | * Points-of-Sales operated by the organization or person. |
||
390 | * |
||
391 | * @param Place|Place[] $hasPOS |
||
392 | * |
||
393 | * @return static |
||
394 | * |
||
395 | * @see http://schema.org/hasPOS |
||
396 | */ |
||
397 | public function hasPOS($hasPOS) |
||
401 | |||
402 | /** |
||
403 | * The height of the item. |
||
404 | * |
||
405 | * @param Distance|Distance[]|QuantitativeValue|QuantitativeValue[] $height |
||
406 | * |
||
407 | * @return static |
||
408 | * |
||
409 | * @see http://schema.org/height |
||
410 | */ |
||
411 | public function height($height) |
||
415 | |||
416 | /** |
||
417 | * A contact location for a person's residence. |
||
418 | * |
||
419 | * @param ContactPoint|ContactPoint[]|Place|Place[] $homeLocation |
||
420 | * |
||
421 | * @return static |
||
422 | * |
||
423 | * @see http://schema.org/homeLocation |
||
424 | */ |
||
425 | public function homeLocation($homeLocation) |
||
429 | |||
430 | /** |
||
431 | * An honorific prefix preceding a Person's name such as Dr/Mrs/Mr. |
||
432 | * |
||
433 | * @param string|string[] $honorificPrefix |
||
434 | * |
||
435 | * @return static |
||
436 | * |
||
437 | * @see http://schema.org/honorificPrefix |
||
438 | */ |
||
439 | public function honorificPrefix($honorificPrefix) |
||
443 | |||
444 | /** |
||
445 | * An honorific suffix preceding a Person's name such as M.D. /PhD/MSCSW. |
||
446 | * |
||
447 | * @param string|string[] $honorificSuffix |
||
448 | * |
||
449 | * @return static |
||
450 | * |
||
451 | * @see http://schema.org/honorificSuffix |
||
452 | */ |
||
453 | public function honorificSuffix($honorificSuffix) |
||
457 | |||
458 | /** |
||
459 | * The International Standard of Industrial Classification of All Economic |
||
460 | * Activities (ISIC), Revision 4 code for a particular organization, |
||
461 | * business person, or place. |
||
462 | * |
||
463 | * @param string|string[] $isicV4 |
||
464 | * |
||
465 | * @return static |
||
466 | * |
||
467 | * @see http://schema.org/isicV4 |
||
468 | */ |
||
469 | public function isicV4($isicV4) |
||
473 | |||
474 | /** |
||
475 | * The job title of the person (for example, Financial Manager). |
||
476 | * |
||
477 | * @param string|string[] $jobTitle |
||
478 | * |
||
479 | * @return static |
||
480 | * |
||
481 | * @see http://schema.org/jobTitle |
||
482 | */ |
||
483 | public function jobTitle($jobTitle) |
||
487 | |||
488 | /** |
||
489 | * The most generic bi-directional social/work relation. |
||
490 | * |
||
491 | * @param Person|Person[] $knows |
||
492 | * |
||
493 | * @return static |
||
494 | * |
||
495 | * @see http://schema.org/knows |
||
496 | */ |
||
497 | public function knows($knows) |
||
501 | |||
502 | /** |
||
503 | * A pointer to products or services offered by the organization or person. |
||
504 | * |
||
505 | * @param Offer|Offer[] $makesOffer |
||
506 | * |
||
507 | * @return static |
||
508 | * |
||
509 | * @see http://schema.org/makesOffer |
||
510 | */ |
||
511 | public function makesOffer($makesOffer) |
||
515 | |||
516 | /** |
||
517 | * An Organization (or ProgramMembership) to which this Person or |
||
518 | * Organization belongs. |
||
519 | * |
||
520 | * @param Organization|Organization[]|ProgramMembership|ProgramMembership[] $memberOf |
||
521 | * |
||
522 | * @return static |
||
523 | * |
||
524 | * @see http://schema.org/memberOf |
||
525 | */ |
||
526 | public function memberOf($memberOf) |
||
530 | |||
531 | /** |
||
532 | * The North American Industry Classification System (NAICS) code for a |
||
533 | * particular organization or business person. |
||
534 | * |
||
535 | * @param string|string[] $naics |
||
536 | * |
||
537 | * @return static |
||
538 | * |
||
539 | * @see http://schema.org/naics |
||
540 | */ |
||
541 | public function naics($naics) |
||
545 | |||
546 | /** |
||
547 | * Nationality of the person. |
||
548 | * |
||
549 | * @param Country|Country[] $nationality |
||
550 | * |
||
551 | * @return static |
||
552 | * |
||
553 | * @see http://schema.org/nationality |
||
554 | */ |
||
555 | public function nationality($nationality) |
||
559 | |||
560 | /** |
||
561 | * The total financial value of the person as calculated by subtracting |
||
562 | * assets from liabilities. |
||
563 | * |
||
564 | * @param MonetaryAmount|MonetaryAmount[]|PriceSpecification|PriceSpecification[] $netWorth |
||
565 | * |
||
566 | * @return static |
||
567 | * |
||
568 | * @see http://schema.org/netWorth |
||
569 | */ |
||
570 | public function netWorth($netWorth) |
||
574 | |||
575 | /** |
||
576 | * Products owned by the organization or person. |
||
577 | * |
||
578 | * @param OwnershipInfo|OwnershipInfo[]|Product|Product[] $owns |
||
579 | * |
||
580 | * @return static |
||
581 | * |
||
582 | * @see http://schema.org/owns |
||
583 | */ |
||
584 | public function owns($owns) |
||
588 | |||
589 | /** |
||
590 | * A parent of this person. |
||
591 | * |
||
592 | * @param Person|Person[] $parent |
||
593 | * |
||
594 | * @return static |
||
595 | * |
||
596 | * @see http://schema.org/parent |
||
597 | */ |
||
598 | public function parent($parent) |
||
602 | |||
603 | /** |
||
604 | * A parents of the person. |
||
605 | * |
||
606 | * @param Person|Person[] $parents |
||
607 | * |
||
608 | * @return static |
||
609 | * |
||
610 | * @see http://schema.org/parents |
||
611 | */ |
||
612 | public function parents($parents) |
||
616 | |||
617 | /** |
||
618 | * Event that this person is a performer or participant in. |
||
619 | * |
||
620 | * @param Event|Event[] $performerIn |
||
621 | * |
||
622 | * @return static |
||
623 | * |
||
624 | * @see http://schema.org/performerIn |
||
625 | */ |
||
626 | public function performerIn($performerIn) |
||
630 | |||
631 | /** |
||
632 | * The publishingPrinciples property indicates (typically via [[URL]]) a |
||
633 | * document describing the editorial principles of an [[Organization]] (or |
||
634 | * individual e.g. a [[Person]] writing a blog) that relate to their |
||
635 | * activities as a publisher, e.g. ethics or diversity policies. When |
||
636 | * applied to a [[CreativeWork]] (e.g. [[NewsArticle]]) the principles are |
||
637 | * those of the party primarily responsible for the creation of the |
||
638 | * [[CreativeWork]]. |
||
639 | * |
||
640 | * While such policies are most typically expressed in natural language, |
||
641 | * sometimes related information (e.g. indicating a [[funder]]) can be |
||
642 | * expressed using schema.org terminology. |
||
643 | * |
||
644 | * @param CreativeWork|CreativeWork[]|string|string[] $publishingPrinciples |
||
645 | * |
||
646 | * @return static |
||
647 | * |
||
648 | * @see http://schema.org/publishingPrinciples |
||
649 | */ |
||
650 | public function publishingPrinciples($publishingPrinciples) |
||
654 | |||
655 | /** |
||
656 | * The most generic familial relation. |
||
657 | * |
||
658 | * @param Person|Person[] $relatedTo |
||
659 | * |
||
660 | * @return static |
||
661 | * |
||
662 | * @see http://schema.org/relatedTo |
||
663 | */ |
||
664 | public function relatedTo($relatedTo) |
||
668 | |||
669 | /** |
||
670 | * A pointer to products or services sought by the organization or person |
||
671 | * (demand). |
||
672 | * |
||
673 | * @param Demand|Demand[] $seeks |
||
674 | * |
||
675 | * @return static |
||
676 | * |
||
677 | * @see http://schema.org/seeks |
||
678 | */ |
||
679 | public function seeks($seeks) |
||
683 | |||
684 | /** |
||
685 | * A sibling of the person. |
||
686 | * |
||
687 | * @param Person|Person[] $sibling |
||
688 | * |
||
689 | * @return static |
||
690 | * |
||
691 | * @see http://schema.org/sibling |
||
692 | */ |
||
693 | public function sibling($sibling) |
||
697 | |||
698 | /** |
||
699 | * A sibling of the person. |
||
700 | * |
||
701 | * @param Person|Person[] $siblings |
||
702 | * |
||
703 | * @return static |
||
704 | * |
||
705 | * @see http://schema.org/siblings |
||
706 | */ |
||
707 | public function siblings($siblings) |
||
711 | |||
712 | /** |
||
713 | * A person or organization that supports a thing through a pledge, promise, |
||
714 | * or financial contribution. e.g. a sponsor of a Medical Study or a |
||
715 | * corporate sponsor of an event. |
||
716 | * |
||
717 | * @param Organization|Organization[]|Person|Person[] $sponsor |
||
718 | * |
||
719 | * @return static |
||
720 | * |
||
721 | * @see http://schema.org/sponsor |
||
722 | */ |
||
723 | public function sponsor($sponsor) |
||
727 | |||
728 | /** |
||
729 | * The person's spouse. |
||
730 | * |
||
731 | * @param Person|Person[] $spouse |
||
732 | * |
||
733 | * @return static |
||
734 | * |
||
735 | * @see http://schema.org/spouse |
||
736 | */ |
||
737 | public function spouse($spouse) |
||
741 | |||
742 | /** |
||
743 | * The Tax / Fiscal ID of the organization or person, e.g. the TIN in the US |
||
744 | * or the CIF/NIF in Spain. |
||
745 | * |
||
746 | * @param string|string[] $taxID |
||
747 | * |
||
748 | * @return static |
||
749 | * |
||
750 | * @see http://schema.org/taxID |
||
751 | */ |
||
752 | public function taxID($taxID) |
||
756 | |||
757 | /** |
||
758 | * The telephone number. |
||
759 | * |
||
760 | * @param string|string[] $telephone |
||
761 | * |
||
762 | * @return static |
||
763 | * |
||
764 | * @see http://schema.org/telephone |
||
765 | */ |
||
766 | public function telephone($telephone) |
||
770 | |||
771 | /** |
||
772 | * The Value-added Tax ID of the organization or person. |
||
773 | * |
||
774 | * @param string|string[] $vatID |
||
775 | * |
||
776 | * @return static |
||
777 | * |
||
778 | * @see http://schema.org/vatID |
||
779 | */ |
||
780 | public function vatID($vatID) |
||
784 | |||
785 | /** |
||
786 | * The weight of the product or person. |
||
787 | * |
||
788 | * @param QuantitativeValue|QuantitativeValue[] $weight |
||
789 | * |
||
790 | * @return static |
||
791 | * |
||
792 | * @see http://schema.org/weight |
||
793 | */ |
||
794 | public function weight($weight) |
||
798 | |||
799 | /** |
||
800 | * A contact location for a person's place of work. |
||
801 | * |
||
802 | * @param ContactPoint|ContactPoint[]|Place|Place[] $workLocation |
||
803 | * |
||
804 | * @return static |
||
805 | * |
||
806 | * @see http://schema.org/workLocation |
||
807 | */ |
||
808 | public function workLocation($workLocation) |
||
812 | |||
813 | /** |
||
814 | * Organizations that the person works for. |
||
815 | * |
||
816 | * @param Organization|Organization[] $worksFor |
||
817 | * |
||
818 | * @return static |
||
819 | * |
||
820 | * @see http://schema.org/worksFor |
||
821 | */ |
||
822 | public function worksFor($worksFor) |
||
826 | |||
827 | } |
||
828 |