Complex classes like Accommodation 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 Accommodation, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
22 | class Accommodation extends BaseType implements AccommodationContract, PlaceContract, ThingContract |
||
23 | { |
||
24 | /** |
||
25 | * A property-value pair representing an additional characteristics of the |
||
26 | * entitity, e.g. a product feature or another characteristic for which |
||
27 | * there is no matching property in schema.org. |
||
28 | * |
||
29 | * Note: Publishers should be aware that applications designed to use |
||
30 | * specific schema.org properties (e.g. http://schema.org/width, |
||
31 | * http://schema.org/color, http://schema.org/gtin13, ...) will typically |
||
32 | * expect such data to be provided using those properties, rather than using |
||
33 | * the generic property/value mechanism. |
||
34 | * |
||
35 | * @param \Spatie\SchemaOrg\Contracts\PropertyValueContract|\Spatie\SchemaOrg\Contracts\PropertyValueContract[] $additionalProperty |
||
36 | * |
||
37 | * @return static |
||
38 | * |
||
39 | * @see http://schema.org/additionalProperty |
||
40 | */ |
||
41 | public function additionalProperty($additionalProperty) |
||
45 | |||
46 | /** |
||
47 | * An additional type for the item, typically used for adding more specific |
||
48 | * types from external vocabularies in microdata syntax. This is a |
||
49 | * relationship between something and a class that the thing is in. In RDFa |
||
50 | * syntax, it is better to use the native RDFa syntax - the 'typeof' |
||
51 | * attribute - for multiple types. Schema.org tools may have only weaker |
||
52 | * understanding of extra types, in particular those defined externally. |
||
53 | * |
||
54 | * @param string|string[] $additionalType |
||
55 | * |
||
56 | * @return static |
||
57 | * |
||
58 | * @see http://schema.org/additionalType |
||
59 | */ |
||
60 | public function additionalType($additionalType) |
||
64 | |||
65 | /** |
||
66 | * Physical address of the item. |
||
67 | * |
||
68 | * @param \Spatie\SchemaOrg\Contracts\PostalAddressContract|\Spatie\SchemaOrg\Contracts\PostalAddressContract[]|string|string[] $address |
||
69 | * |
||
70 | * @return static |
||
71 | * |
||
72 | * @see http://schema.org/address |
||
73 | */ |
||
74 | public function address($address) |
||
78 | |||
79 | /** |
||
80 | * The overall rating, based on a collection of reviews or ratings, of the |
||
81 | * item. |
||
82 | * |
||
83 | * @param \Spatie\SchemaOrg\Contracts\AggregateRatingContract|\Spatie\SchemaOrg\Contracts\AggregateRatingContract[] $aggregateRating |
||
84 | * |
||
85 | * @return static |
||
86 | * |
||
87 | * @see http://schema.org/aggregateRating |
||
88 | */ |
||
89 | public function aggregateRating($aggregateRating) |
||
93 | |||
94 | /** |
||
95 | * An alias for the item. |
||
96 | * |
||
97 | * @param string|string[] $alternateName |
||
98 | * |
||
99 | * @return static |
||
100 | * |
||
101 | * @see http://schema.org/alternateName |
||
102 | */ |
||
103 | public function alternateName($alternateName) |
||
107 | |||
108 | /** |
||
109 | * An amenity feature (e.g. a characteristic or service) of the |
||
110 | * Accommodation. This generic property does not make a statement about |
||
111 | * whether the feature is included in an offer for the main accommodation or |
||
112 | * available at extra costs. |
||
113 | * |
||
114 | * @param \Spatie\SchemaOrg\Contracts\LocationFeatureSpecificationContract|\Spatie\SchemaOrg\Contracts\LocationFeatureSpecificationContract[] $amenityFeature |
||
115 | * |
||
116 | * @return static |
||
117 | * |
||
118 | * @see http://schema.org/amenityFeature |
||
119 | */ |
||
120 | public function amenityFeature($amenityFeature) |
||
124 | |||
125 | /** |
||
126 | * A short textual code (also called "store code") that uniquely identifies |
||
127 | * a place of business. The code is typically assigned by the |
||
128 | * parentOrganization and used in structured URLs. |
||
129 | * |
||
130 | * For example, in the URL |
||
131 | * http://www.starbucks.co.uk/store-locator/etc/detail/3047 the code "3047" |
||
132 | * is a branchCode for a particular branch. |
||
133 | * |
||
134 | * @param string|string[] $branchCode |
||
135 | * |
||
136 | * @return static |
||
137 | * |
||
138 | * @see http://schema.org/branchCode |
||
139 | */ |
||
140 | public function branchCode($branchCode) |
||
144 | |||
145 | /** |
||
146 | * The basic containment relation between a place and one that contains it. |
||
147 | * |
||
148 | * @param \Spatie\SchemaOrg\Contracts\PlaceContract|\Spatie\SchemaOrg\Contracts\PlaceContract[] $containedIn |
||
149 | * |
||
150 | * @return static |
||
151 | * |
||
152 | * @see http://schema.org/containedIn |
||
153 | */ |
||
154 | public function containedIn($containedIn) |
||
158 | |||
159 | /** |
||
160 | * The basic containment relation between a place and one that contains it. |
||
161 | * |
||
162 | * @param \Spatie\SchemaOrg\Contracts\PlaceContract|\Spatie\SchemaOrg\Contracts\PlaceContract[] $containedInPlace |
||
163 | * |
||
164 | * @return static |
||
165 | * |
||
166 | * @see http://schema.org/containedInPlace |
||
167 | */ |
||
168 | public function containedInPlace($containedInPlace) |
||
172 | |||
173 | /** |
||
174 | * The basic containment relation between a place and another that it |
||
175 | * contains. |
||
176 | * |
||
177 | * @param \Spatie\SchemaOrg\Contracts\PlaceContract|\Spatie\SchemaOrg\Contracts\PlaceContract[] $containsPlace |
||
178 | * |
||
179 | * @return static |
||
180 | * |
||
181 | * @see http://schema.org/containsPlace |
||
182 | */ |
||
183 | public function containsPlace($containsPlace) |
||
187 | |||
188 | /** |
||
189 | * A description of the item. |
||
190 | * |
||
191 | * @param string|string[] $description |
||
192 | * |
||
193 | * @return static |
||
194 | * |
||
195 | * @see http://schema.org/description |
||
196 | */ |
||
197 | public function description($description) |
||
201 | |||
202 | /** |
||
203 | * A sub property of description. A short description of the item used to |
||
204 | * disambiguate from other, similar items. Information from other properties |
||
205 | * (in particular, name) may be necessary for the description to be useful |
||
206 | * for disambiguation. |
||
207 | * |
||
208 | * @param string|string[] $disambiguatingDescription |
||
209 | * |
||
210 | * @return static |
||
211 | * |
||
212 | * @see http://schema.org/disambiguatingDescription |
||
213 | */ |
||
214 | public function disambiguatingDescription($disambiguatingDescription) |
||
218 | |||
219 | /** |
||
220 | * Upcoming or past event associated with this place, organization, or |
||
221 | * action. |
||
222 | * |
||
223 | * @param \Spatie\SchemaOrg\Contracts\EventContract|\Spatie\SchemaOrg\Contracts\EventContract[] $event |
||
224 | * |
||
225 | * @return static |
||
226 | * |
||
227 | * @see http://schema.org/event |
||
228 | */ |
||
229 | public function event($event) |
||
233 | |||
234 | /** |
||
235 | * Upcoming or past events associated with this place or organization. |
||
236 | * |
||
237 | * @param \Spatie\SchemaOrg\Contracts\EventContract|\Spatie\SchemaOrg\Contracts\EventContract[] $events |
||
238 | * |
||
239 | * @return static |
||
240 | * |
||
241 | * @see http://schema.org/events |
||
242 | */ |
||
243 | public function events($events) |
||
247 | |||
248 | /** |
||
249 | * The fax number. |
||
250 | * |
||
251 | * @param string|string[] $faxNumber |
||
252 | * |
||
253 | * @return static |
||
254 | * |
||
255 | * @see http://schema.org/faxNumber |
||
256 | */ |
||
257 | public function faxNumber($faxNumber) |
||
261 | |||
262 | /** |
||
263 | * The size of the accommodation, e.g. in square meter or squarefoot. |
||
264 | * Typical unit code(s): MTK for square meter, FTK for square foot, or YDK |
||
265 | * for square yard |
||
266 | * |
||
267 | * @param \Spatie\SchemaOrg\Contracts\QuantitativeValueContract|\Spatie\SchemaOrg\Contracts\QuantitativeValueContract[] $floorSize |
||
268 | * |
||
269 | * @return static |
||
270 | * |
||
271 | * @see http://schema.org/floorSize |
||
272 | */ |
||
273 | public function floorSize($floorSize) |
||
277 | |||
278 | /** |
||
279 | * The geo coordinates of the place. |
||
280 | * |
||
281 | * @param \Spatie\SchemaOrg\Contracts\GeoCoordinatesContract|\Spatie\SchemaOrg\Contracts\GeoCoordinatesContract[]|\Spatie\SchemaOrg\Contracts\GeoShapeContract|\Spatie\SchemaOrg\Contracts\GeoShapeContract[] $geo |
||
282 | * |
||
283 | * @return static |
||
284 | * |
||
285 | * @see http://schema.org/geo |
||
286 | */ |
||
287 | public function geo($geo) |
||
291 | |||
292 | /** |
||
293 | * The [Global Location Number](http://www.gs1.org/gln) (GLN, sometimes also |
||
294 | * referred to as International Location Number or ILN) of the respective |
||
295 | * organization, person, or place. The GLN is a 13-digit number used to |
||
296 | * identify parties and physical locations. |
||
297 | * |
||
298 | * @param string|string[] $globalLocationNumber |
||
299 | * |
||
300 | * @return static |
||
301 | * |
||
302 | * @see http://schema.org/globalLocationNumber |
||
303 | */ |
||
304 | public function globalLocationNumber($globalLocationNumber) |
||
308 | |||
309 | /** |
||
310 | * A URL to a map of the place. |
||
311 | * |
||
312 | * @param \Spatie\SchemaOrg\Contracts\MapContract|\Spatie\SchemaOrg\Contracts\MapContract[]|string|string[] $hasMap |
||
313 | * |
||
314 | * @return static |
||
315 | * |
||
316 | * @see http://schema.org/hasMap |
||
317 | */ |
||
318 | public function hasMap($hasMap) |
||
322 | |||
323 | /** |
||
324 | * The identifier property represents any kind of identifier for any kind of |
||
325 | * [[Thing]], such as ISBNs, GTIN codes, UUIDs etc. Schema.org provides |
||
326 | * dedicated properties for representing many of these, either as textual |
||
327 | * strings or as URL (URI) links. See [background |
||
328 | * notes](/docs/datamodel.html#identifierBg) for more details. |
||
329 | * |
||
330 | * @param \Spatie\SchemaOrg\Contracts\PropertyValueContract|\Spatie\SchemaOrg\Contracts\PropertyValueContract[]|string|string[] $identifier |
||
331 | * |
||
332 | * @return static |
||
333 | * |
||
334 | * @see http://schema.org/identifier |
||
335 | */ |
||
336 | public function identifier($identifier) |
||
340 | |||
341 | /** |
||
342 | * An image of the item. This can be a [[URL]] or a fully described |
||
343 | * [[ImageObject]]. |
||
344 | * |
||
345 | * @param \Spatie\SchemaOrg\Contracts\ImageObjectContract|\Spatie\SchemaOrg\Contracts\ImageObjectContract[]|string|string[] $image |
||
346 | * |
||
347 | * @return static |
||
348 | * |
||
349 | * @see http://schema.org/image |
||
350 | */ |
||
351 | public function image($image) |
||
355 | |||
356 | /** |
||
357 | * A flag to signal that the item, event, or place is accessible for free. |
||
358 | * |
||
359 | * @param bool|bool[] $isAccessibleForFree |
||
360 | * |
||
361 | * @return static |
||
362 | * |
||
363 | * @see http://schema.org/isAccessibleForFree |
||
364 | */ |
||
365 | public function isAccessibleForFree($isAccessibleForFree) |
||
369 | |||
370 | /** |
||
371 | * The International Standard of Industrial Classification of All Economic |
||
372 | * Activities (ISIC), Revision 4 code for a particular organization, |
||
373 | * business person, or place. |
||
374 | * |
||
375 | * @param string|string[] $isicV4 |
||
376 | * |
||
377 | * @return static |
||
378 | * |
||
379 | * @see http://schema.org/isicV4 |
||
380 | */ |
||
381 | public function isicV4($isicV4) |
||
385 | |||
386 | /** |
||
387 | * The latitude of a location. For example ```37.42242``` ([WGS |
||
388 | * 84](https://en.wikipedia.org/wiki/World_Geodetic_System)). |
||
389 | * |
||
390 | * @param float|float[]|int|int[]|string|string[] $latitude |
||
391 | * |
||
392 | * @return static |
||
393 | * |
||
394 | * @see http://schema.org/latitude |
||
395 | */ |
||
396 | public function latitude($latitude) |
||
400 | |||
401 | /** |
||
402 | * An associated logo. |
||
403 | * |
||
404 | * @param \Spatie\SchemaOrg\Contracts\ImageObjectContract|\Spatie\SchemaOrg\Contracts\ImageObjectContract[]|string|string[] $logo |
||
405 | * |
||
406 | * @return static |
||
407 | * |
||
408 | * @see http://schema.org/logo |
||
409 | */ |
||
410 | public function logo($logo) |
||
414 | |||
415 | /** |
||
416 | * The longitude of a location. For example ```-122.08585``` ([WGS |
||
417 | * 84](https://en.wikipedia.org/wiki/World_Geodetic_System)). |
||
418 | * |
||
419 | * @param float|float[]|int|int[]|string|string[] $longitude |
||
420 | * |
||
421 | * @return static |
||
422 | * |
||
423 | * @see http://schema.org/longitude |
||
424 | */ |
||
425 | public function longitude($longitude) |
||
429 | |||
430 | /** |
||
431 | * Indicates a page (or other CreativeWork) for which this thing is the main |
||
432 | * entity being described. See [background |
||
433 | * notes](/docs/datamodel.html#mainEntityBackground) for details. |
||
434 | * |
||
435 | * @param \Spatie\SchemaOrg\Contracts\CreativeWorkContract|\Spatie\SchemaOrg\Contracts\CreativeWorkContract[]|string|string[] $mainEntityOfPage |
||
436 | * |
||
437 | * @return static |
||
438 | * |
||
439 | * @see http://schema.org/mainEntityOfPage |
||
440 | */ |
||
441 | public function mainEntityOfPage($mainEntityOfPage) |
||
445 | |||
446 | /** |
||
447 | * A URL to a map of the place. |
||
448 | * |
||
449 | * @param string|string[] $map |
||
450 | * |
||
451 | * @return static |
||
452 | * |
||
453 | * @see http://schema.org/map |
||
454 | */ |
||
455 | public function map($map) |
||
459 | |||
460 | /** |
||
461 | * A URL to a map of the place. |
||
462 | * |
||
463 | * @param string|string[] $maps |
||
464 | * |
||
465 | * @return static |
||
466 | * |
||
467 | * @see http://schema.org/maps |
||
468 | */ |
||
469 | public function maps($maps) |
||
473 | |||
474 | /** |
||
475 | * The total number of individuals that may attend an event or venue. |
||
476 | * |
||
477 | * @param int|int[] $maximumAttendeeCapacity |
||
478 | * |
||
479 | * @return static |
||
480 | * |
||
481 | * @see http://schema.org/maximumAttendeeCapacity |
||
482 | */ |
||
483 | public function maximumAttendeeCapacity($maximumAttendeeCapacity) |
||
487 | |||
488 | /** |
||
489 | * The name of the item. |
||
490 | * |
||
491 | * @param string|string[] $name |
||
492 | * |
||
493 | * @return static |
||
494 | * |
||
495 | * @see http://schema.org/name |
||
496 | */ |
||
497 | public function name($name) |
||
501 | |||
502 | /** |
||
503 | * The number of rooms (excluding bathrooms and closets) of the |
||
504 | * accommodation or lodging business. |
||
505 | * Typical unit code(s): ROM for room or C62 for no unit. The type of room |
||
506 | * can be put in the unitText property of the QuantitativeValue. |
||
507 | * |
||
508 | * @param \Spatie\SchemaOrg\Contracts\QuantitativeValueContract|\Spatie\SchemaOrg\Contracts\QuantitativeValueContract[]|float|float[]|int|int[] $numberOfRooms |
||
509 | * |
||
510 | * @return static |
||
511 | * |
||
512 | * @see http://schema.org/numberOfRooms |
||
513 | */ |
||
514 | public function numberOfRooms($numberOfRooms) |
||
518 | |||
519 | /** |
||
520 | * The opening hours of a certain place. |
||
521 | * |
||
522 | * @param \Spatie\SchemaOrg\Contracts\OpeningHoursSpecificationContract|\Spatie\SchemaOrg\Contracts\OpeningHoursSpecificationContract[] $openingHoursSpecification |
||
523 | * |
||
524 | * @return static |
||
525 | * |
||
526 | * @see http://schema.org/openingHoursSpecification |
||
527 | */ |
||
528 | public function openingHoursSpecification($openingHoursSpecification) |
||
532 | |||
533 | /** |
||
534 | * Indications regarding the permitted usage of the accommodation. |
||
535 | * |
||
536 | * @param string|string[] $permittedUsage |
||
537 | * |
||
538 | * @return static |
||
539 | * |
||
540 | * @see http://schema.org/permittedUsage |
||
541 | */ |
||
542 | public function permittedUsage($permittedUsage) |
||
546 | |||
547 | /** |
||
548 | * Indicates whether pets are allowed to enter the accommodation or lodging |
||
549 | * business. More detailed information can be put in a text value. |
||
550 | * |
||
551 | * @param bool|bool[]|string|string[] $petsAllowed |
||
552 | * |
||
553 | * @return static |
||
554 | * |
||
555 | * @see http://schema.org/petsAllowed |
||
556 | */ |
||
557 | public function petsAllowed($petsAllowed) |
||
561 | |||
562 | /** |
||
563 | * A photograph of this place. |
||
564 | * |
||
565 | * @param \Spatie\SchemaOrg\Contracts\ImageObjectContract|\Spatie\SchemaOrg\Contracts\ImageObjectContract[]|\Spatie\SchemaOrg\Contracts\PhotographContract|\Spatie\SchemaOrg\Contracts\PhotographContract[] $photo |
||
566 | * |
||
567 | * @return static |
||
568 | * |
||
569 | * @see http://schema.org/photo |
||
570 | */ |
||
571 | public function photo($photo) |
||
575 | |||
576 | /** |
||
577 | * Photographs of this place. |
||
578 | * |
||
579 | * @param \Spatie\SchemaOrg\Contracts\ImageObjectContract|\Spatie\SchemaOrg\Contracts\ImageObjectContract[]|\Spatie\SchemaOrg\Contracts\PhotographContract|\Spatie\SchemaOrg\Contracts\PhotographContract[] $photos |
||
580 | * |
||
581 | * @return static |
||
582 | * |
||
583 | * @see http://schema.org/photos |
||
584 | */ |
||
585 | public function photos($photos) |
||
589 | |||
590 | /** |
||
591 | * Indicates a potential Action, which describes an idealized action in |
||
592 | * which this thing would play an 'object' role. |
||
593 | * |
||
594 | * @param \Spatie\SchemaOrg\Contracts\ActionContract|\Spatie\SchemaOrg\Contracts\ActionContract[] $potentialAction |
||
595 | * |
||
596 | * @return static |
||
597 | * |
||
598 | * @see http://schema.org/potentialAction |
||
599 | */ |
||
600 | public function potentialAction($potentialAction) |
||
604 | |||
605 | /** |
||
606 | * A flag to signal that the [[Place]] is open to public visitors. If this |
||
607 | * property is omitted there is no assumed default boolean value |
||
608 | * |
||
609 | * @param bool|bool[] $publicAccess |
||
610 | * |
||
611 | * @return static |
||
612 | * |
||
613 | * @see http://schema.org/publicAccess |
||
614 | */ |
||
615 | public function publicAccess($publicAccess) |
||
619 | |||
620 | /** |
||
621 | * A review of the item. |
||
622 | * |
||
623 | * @param \Spatie\SchemaOrg\Contracts\ReviewContract|\Spatie\SchemaOrg\Contracts\ReviewContract[] $review |
||
624 | * |
||
625 | * @return static |
||
626 | * |
||
627 | * @see http://schema.org/review |
||
628 | */ |
||
629 | public function review($review) |
||
633 | |||
634 | /** |
||
635 | * Review of the item. |
||
636 | * |
||
637 | * @param \Spatie\SchemaOrg\Contracts\ReviewContract|\Spatie\SchemaOrg\Contracts\ReviewContract[] $reviews |
||
638 | * |
||
639 | * @return static |
||
640 | * |
||
641 | * @see http://schema.org/reviews |
||
642 | */ |
||
643 | public function reviews($reviews) |
||
647 | |||
648 | /** |
||
649 | * URL of a reference Web page that unambiguously indicates the item's |
||
650 | * identity. E.g. the URL of the item's Wikipedia page, Wikidata entry, or |
||
651 | * official website. |
||
652 | * |
||
653 | * @param string|string[] $sameAs |
||
654 | * |
||
655 | * @return static |
||
656 | * |
||
657 | * @see http://schema.org/sameAs |
||
658 | */ |
||
659 | public function sameAs($sameAs) |
||
663 | |||
664 | /** |
||
665 | * A slogan or motto associated with the item. |
||
666 | * |
||
667 | * @param string|string[] $slogan |
||
668 | * |
||
669 | * @return static |
||
670 | * |
||
671 | * @see http://schema.org/slogan |
||
672 | */ |
||
673 | public function slogan($slogan) |
||
677 | |||
678 | /** |
||
679 | * Indicates whether it is allowed to smoke in the place, e.g. in the |
||
680 | * restaurant, hotel or hotel room. |
||
681 | * |
||
682 | * @param bool|bool[] $smokingAllowed |
||
683 | * |
||
684 | * @return static |
||
685 | * |
||
686 | * @see http://schema.org/smokingAllowed |
||
687 | */ |
||
688 | public function smokingAllowed($smokingAllowed) |
||
692 | |||
693 | /** |
||
694 | * The special opening hours of a certain place. |
||
695 | * |
||
696 | * Use this to explicitly override general opening hours brought in scope by |
||
697 | * [[openingHoursSpecification]] or [[openingHours]]. |
||
698 | * |
||
699 | * @param \Spatie\SchemaOrg\Contracts\OpeningHoursSpecificationContract|\Spatie\SchemaOrg\Contracts\OpeningHoursSpecificationContract[] $specialOpeningHoursSpecification |
||
700 | * |
||
701 | * @return static |
||
702 | * |
||
703 | * @see http://schema.org/specialOpeningHoursSpecification |
||
704 | */ |
||
705 | public function specialOpeningHoursSpecification($specialOpeningHoursSpecification) |
||
709 | |||
710 | /** |
||
711 | * A CreativeWork or Event about this Thing. |
||
712 | * |
||
713 | * @param \Spatie\SchemaOrg\Contracts\CreativeWorkContract|\Spatie\SchemaOrg\Contracts\CreativeWorkContract[]|\Spatie\SchemaOrg\Contracts\EventContract|\Spatie\SchemaOrg\Contracts\EventContract[] $subjectOf |
||
714 | * |
||
715 | * @return static |
||
716 | * |
||
717 | * @see http://schema.org/subjectOf |
||
718 | */ |
||
719 | public function subjectOf($subjectOf) |
||
723 | |||
724 | /** |
||
725 | * The telephone number. |
||
726 | * |
||
727 | * @param string|string[] $telephone |
||
728 | * |
||
729 | * @return static |
||
730 | * |
||
731 | * @see http://schema.org/telephone |
||
732 | */ |
||
733 | public function telephone($telephone) |
||
737 | |||
738 | /** |
||
739 | * URL of the item. |
||
740 | * |
||
741 | * @param string|string[] $url |
||
742 | * |
||
743 | * @return static |
||
744 | * |
||
745 | * @see http://schema.org/url |
||
746 | */ |
||
747 | public function url($url) |
||
751 | |||
752 | } |
||
753 |