Complex classes like Offer 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 Offer, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 22 | class Offer extends BaseType |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * The payment method(s) accepted by seller for this offer. |
||
| 26 | * |
||
| 27 | * @param LoanOrCredit|LoanOrCredit[]|PaymentMethod|PaymentMethod[] $acceptedPaymentMethod |
||
| 28 | * |
||
| 29 | * @return static |
||
| 30 | * |
||
| 31 | * @see http://schema.org/acceptedPaymentMethod |
||
| 32 | */ |
||
| 33 | public function acceptedPaymentMethod($acceptedPaymentMethod) |
||
| 37 | |||
| 38 | /** |
||
| 39 | * An additional offer that can only be obtained in combination with the |
||
| 40 | * first base offer (e.g. supplements and extensions that are available for |
||
| 41 | * a surcharge). |
||
| 42 | * |
||
| 43 | * @param Offer|Offer[] $addOn |
||
| 44 | * |
||
| 45 | * @return static |
||
| 46 | * |
||
| 47 | * @see http://schema.org/addOn |
||
| 48 | */ |
||
| 49 | public function addOn($addOn) |
||
| 53 | |||
| 54 | /** |
||
| 55 | * The amount of time that is required between accepting the offer and the |
||
| 56 | * actual usage of the resource or service. |
||
| 57 | * |
||
| 58 | * @param QuantitativeValue|QuantitativeValue[] $advanceBookingRequirement |
||
| 59 | * |
||
| 60 | * @return static |
||
| 61 | * |
||
| 62 | * @see http://schema.org/advanceBookingRequirement |
||
| 63 | */ |
||
| 64 | public function advanceBookingRequirement($advanceBookingRequirement) |
||
| 68 | |||
| 69 | /** |
||
| 70 | * The overall rating, based on a collection of reviews or ratings, of the |
||
| 71 | * item. |
||
| 72 | * |
||
| 73 | * @param AggregateRating|AggregateRating[] $aggregateRating |
||
| 74 | * |
||
| 75 | * @return static |
||
| 76 | * |
||
| 77 | * @see http://schema.org/aggregateRating |
||
| 78 | */ |
||
| 79 | public function aggregateRating($aggregateRating) |
||
| 83 | |||
| 84 | /** |
||
| 85 | * The geographic area where a service or offered item is provided. |
||
| 86 | * |
||
| 87 | * @param AdministrativeArea|AdministrativeArea[]|GeoShape|GeoShape[]|Place|Place[]|string|string[] $areaServed |
||
| 88 | * |
||
| 89 | * @return static |
||
| 90 | * |
||
| 91 | * @see http://schema.org/areaServed |
||
| 92 | */ |
||
| 93 | public function areaServed($areaServed) |
||
| 97 | |||
| 98 | /** |
||
| 99 | * The availability of this item—for example In stock, Out of stock, |
||
| 100 | * Pre-order, etc. |
||
| 101 | * |
||
| 102 | * @param ItemAvailability|ItemAvailability[] $availability |
||
| 103 | * |
||
| 104 | * @return static |
||
| 105 | * |
||
| 106 | * @see http://schema.org/availability |
||
| 107 | */ |
||
| 108 | public function availability($availability) |
||
| 112 | |||
| 113 | /** |
||
| 114 | * The end of the availability of the product or service included in the |
||
| 115 | * offer. |
||
| 116 | * |
||
| 117 | * @param \DateTimeInterface|\DateTimeInterface[] $availabilityEnds |
||
| 118 | * |
||
| 119 | * @return static |
||
| 120 | * |
||
| 121 | * @see http://schema.org/availabilityEnds |
||
| 122 | */ |
||
| 123 | public function availabilityEnds($availabilityEnds) |
||
| 127 | |||
| 128 | /** |
||
| 129 | * The beginning of the availability of the product or service included in |
||
| 130 | * the offer. |
||
| 131 | * |
||
| 132 | * @param \DateTimeInterface|\DateTimeInterface[] $availabilityStarts |
||
| 133 | * |
||
| 134 | * @return static |
||
| 135 | * |
||
| 136 | * @see http://schema.org/availabilityStarts |
||
| 137 | */ |
||
| 138 | public function availabilityStarts($availabilityStarts) |
||
| 142 | |||
| 143 | /** |
||
| 144 | * The place(s) from which the offer can be obtained (e.g. store locations). |
||
| 145 | * |
||
| 146 | * @param Place|Place[] $availableAtOrFrom |
||
| 147 | * |
||
| 148 | * @return static |
||
| 149 | * |
||
| 150 | * @see http://schema.org/availableAtOrFrom |
||
| 151 | */ |
||
| 152 | public function availableAtOrFrom($availableAtOrFrom) |
||
| 156 | |||
| 157 | /** |
||
| 158 | * The delivery method(s) available for this offer. |
||
| 159 | * |
||
| 160 | * @param DeliveryMethod|DeliveryMethod[] $availableDeliveryMethod |
||
| 161 | * |
||
| 162 | * @return static |
||
| 163 | * |
||
| 164 | * @see http://schema.org/availableDeliveryMethod |
||
| 165 | */ |
||
| 166 | public function availableDeliveryMethod($availableDeliveryMethod) |
||
| 170 | |||
| 171 | /** |
||
| 172 | * The business function (e.g. sell, lease, repair, dispose) of the offer or |
||
| 173 | * component of a bundle (TypeAndQuantityNode). The default is |
||
| 174 | * http://purl.org/goodrelations/v1#Sell. |
||
| 175 | * |
||
| 176 | * @param BusinessFunction|BusinessFunction[] $businessFunction |
||
| 177 | * |
||
| 178 | * @return static |
||
| 179 | * |
||
| 180 | * @see http://schema.org/businessFunction |
||
| 181 | */ |
||
| 182 | public function businessFunction($businessFunction) |
||
| 186 | |||
| 187 | /** |
||
| 188 | * A category for the item. Greater signs or slashes can be used to |
||
| 189 | * informally indicate a category hierarchy. |
||
| 190 | * |
||
| 191 | * @param Thing|Thing[]|string|string[] $category |
||
| 192 | * |
||
| 193 | * @return static |
||
| 194 | * |
||
| 195 | * @see http://schema.org/category |
||
| 196 | */ |
||
| 197 | public function category($category) |
||
| 201 | |||
| 202 | /** |
||
| 203 | * The typical delay between the receipt of the order and the goods either |
||
| 204 | * leaving the warehouse or being prepared for pickup, in case the delivery |
||
| 205 | * method is on site pickup. |
||
| 206 | * |
||
| 207 | * @param QuantitativeValue|QuantitativeValue[] $deliveryLeadTime |
||
| 208 | * |
||
| 209 | * @return static |
||
| 210 | * |
||
| 211 | * @see http://schema.org/deliveryLeadTime |
||
| 212 | */ |
||
| 213 | public function deliveryLeadTime($deliveryLeadTime) |
||
| 217 | |||
| 218 | /** |
||
| 219 | * The type(s) of customers for which the given offer is valid. |
||
| 220 | * |
||
| 221 | * @param BusinessEntityType|BusinessEntityType[] $eligibleCustomerType |
||
| 222 | * |
||
| 223 | * @return static |
||
| 224 | * |
||
| 225 | * @see http://schema.org/eligibleCustomerType |
||
| 226 | */ |
||
| 227 | public function eligibleCustomerType($eligibleCustomerType) |
||
| 231 | |||
| 232 | /** |
||
| 233 | * The duration for which the given offer is valid. |
||
| 234 | * |
||
| 235 | * @param QuantitativeValue|QuantitativeValue[] $eligibleDuration |
||
| 236 | * |
||
| 237 | * @return static |
||
| 238 | * |
||
| 239 | * @see http://schema.org/eligibleDuration |
||
| 240 | */ |
||
| 241 | public function eligibleDuration($eligibleDuration) |
||
| 245 | |||
| 246 | /** |
||
| 247 | * The interval and unit of measurement of ordering quantities for which the |
||
| 248 | * offer or price specification is valid. This allows e.g. specifying that a |
||
| 249 | * certain freight charge is valid only for a certain quantity. |
||
| 250 | * |
||
| 251 | * @param QuantitativeValue|QuantitativeValue[] $eligibleQuantity |
||
| 252 | * |
||
| 253 | * @return static |
||
| 254 | * |
||
| 255 | * @see http://schema.org/eligibleQuantity |
||
| 256 | */ |
||
| 257 | public function eligibleQuantity($eligibleQuantity) |
||
| 261 | |||
| 262 | /** |
||
| 263 | * The ISO 3166-1 (ISO 3166-1 alpha-2) or ISO 3166-2 code, the place, or the |
||
| 264 | * GeoShape for the geo-political region(s) for which the offer or delivery |
||
| 265 | * charge specification is valid. |
||
| 266 | * |
||
| 267 | * See also [[ineligibleRegion]]. |
||
| 268 | * |
||
| 269 | * @param GeoShape|GeoShape[]|Place|Place[]|string|string[] $eligibleRegion |
||
| 270 | * |
||
| 271 | * @return static |
||
| 272 | * |
||
| 273 | * @see http://schema.org/eligibleRegion |
||
| 274 | */ |
||
| 275 | public function eligibleRegion($eligibleRegion) |
||
| 279 | |||
| 280 | /** |
||
| 281 | * The transaction volume, in a monetary unit, for which the offer or price |
||
| 282 | * specification is valid, e.g. for indicating a minimal purchasing volume, |
||
| 283 | * to express free shipping above a certain order volume, or to limit the |
||
| 284 | * acceptance of credit cards to purchases to a certain minimal amount. |
||
| 285 | * |
||
| 286 | * @param PriceSpecification|PriceSpecification[] $eligibleTransactionVolume |
||
| 287 | * |
||
| 288 | * @return static |
||
| 289 | * |
||
| 290 | * @see http://schema.org/eligibleTransactionVolume |
||
| 291 | */ |
||
| 292 | public function eligibleTransactionVolume($eligibleTransactionVolume) |
||
| 296 | |||
| 297 | /** |
||
| 298 | * The GTIN-12 code of the product, or the product to which the offer |
||
| 299 | * refers. The GTIN-12 is the 12-digit GS1 Identification Key composed of a |
||
| 300 | * U.P.C. Company Prefix, Item Reference, and Check Digit used to identify |
||
| 301 | * trade items. See [GS1 GTIN |
||
| 302 | * Summary](http://www.gs1.org/barcodes/technical/idkeys/gtin) for more |
||
| 303 | * details. |
||
| 304 | * |
||
| 305 | * @param string|string[] $gtin12 |
||
| 306 | * |
||
| 307 | * @return static |
||
| 308 | * |
||
| 309 | * @see http://schema.org/gtin12 |
||
| 310 | */ |
||
| 311 | public function gtin12($gtin12) |
||
| 315 | |||
| 316 | /** |
||
| 317 | * The GTIN-13 code of the product, or the product to which the offer |
||
| 318 | * refers. This is equivalent to 13-digit ISBN codes and EAN UCC-13. Former |
||
| 319 | * 12-digit UPC codes can be converted into a GTIN-13 code by simply adding |
||
| 320 | * a preceeding zero. See [GS1 GTIN |
||
| 321 | * Summary](http://www.gs1.org/barcodes/technical/idkeys/gtin) for more |
||
| 322 | * details. |
||
| 323 | * |
||
| 324 | * @param string|string[] $gtin13 |
||
| 325 | * |
||
| 326 | * @return static |
||
| 327 | * |
||
| 328 | * @see http://schema.org/gtin13 |
||
| 329 | */ |
||
| 330 | public function gtin13($gtin13) |
||
| 334 | |||
| 335 | /** |
||
| 336 | * The GTIN-14 code of the product, or the product to which the offer |
||
| 337 | * refers. See [GS1 GTIN |
||
| 338 | * Summary](http://www.gs1.org/barcodes/technical/idkeys/gtin) for more |
||
| 339 | * details. |
||
| 340 | * |
||
| 341 | * @param string|string[] $gtin14 |
||
| 342 | * |
||
| 343 | * @return static |
||
| 344 | * |
||
| 345 | * @see http://schema.org/gtin14 |
||
| 346 | */ |
||
| 347 | public function gtin14($gtin14) |
||
| 351 | |||
| 352 | /** |
||
| 353 | * The [GTIN-8](http://apps.gs1.org/GDD/glossary/Pages/GTIN-8.aspx) code of |
||
| 354 | * the product, or the product to which the offer refers. This code is also |
||
| 355 | * known as EAN/UCC-8 or 8-digit EAN. See [GS1 GTIN |
||
| 356 | * Summary](http://www.gs1.org/barcodes/technical/idkeys/gtin) for more |
||
| 357 | * details. |
||
| 358 | * |
||
| 359 | * @param string|string[] $gtin8 |
||
| 360 | * |
||
| 361 | * @return static |
||
| 362 | * |
||
| 363 | * @see http://schema.org/gtin8 |
||
| 364 | */ |
||
| 365 | public function gtin8($gtin8) |
||
| 369 | |||
| 370 | /** |
||
| 371 | * This links to a node or nodes indicating the exact quantity of the |
||
| 372 | * products included in the offer. |
||
| 373 | * |
||
| 374 | * @param TypeAndQuantityNode|TypeAndQuantityNode[] $includesObject |
||
| 375 | * |
||
| 376 | * @return static |
||
| 377 | * |
||
| 378 | * @see http://schema.org/includesObject |
||
| 379 | */ |
||
| 380 | public function includesObject($includesObject) |
||
| 384 | |||
| 385 | /** |
||
| 386 | * The ISO 3166-1 (ISO 3166-1 alpha-2) or ISO 3166-2 code, the place, or the |
||
| 387 | * GeoShape for the geo-political region(s) for which the offer or delivery |
||
| 388 | * charge specification is not valid, e.g. a region where the transaction is |
||
| 389 | * not allowed. |
||
| 390 | * |
||
| 391 | * See also [[eligibleRegion]]. |
||
| 392 | * |
||
| 393 | * @param GeoShape|GeoShape[]|Place|Place[]|string|string[] $ineligibleRegion |
||
| 394 | * |
||
| 395 | * @return static |
||
| 396 | * |
||
| 397 | * @see http://schema.org/ineligibleRegion |
||
| 398 | */ |
||
| 399 | public function ineligibleRegion($ineligibleRegion) |
||
| 403 | |||
| 404 | /** |
||
| 405 | * The current approximate inventory level for the item or items. |
||
| 406 | * |
||
| 407 | * @param QuantitativeValue|QuantitativeValue[] $inventoryLevel |
||
| 408 | * |
||
| 409 | * @return static |
||
| 410 | * |
||
| 411 | * @see http://schema.org/inventoryLevel |
||
| 412 | */ |
||
| 413 | public function inventoryLevel($inventoryLevel) |
||
| 417 | |||
| 418 | /** |
||
| 419 | * A predefined value from OfferItemCondition or a textual description of |
||
| 420 | * the condition of the product or service, or the products or services |
||
| 421 | * included in the offer. |
||
| 422 | * |
||
| 423 | * @param OfferItemCondition|OfferItemCondition[] $itemCondition |
||
| 424 | * |
||
| 425 | * @return static |
||
| 426 | * |
||
| 427 | * @see http://schema.org/itemCondition |
||
| 428 | */ |
||
| 429 | public function itemCondition($itemCondition) |
||
| 433 | |||
| 434 | /** |
||
| 435 | * The item being offered. |
||
| 436 | * |
||
| 437 | * @param Product|Product[]|Service|Service[] $itemOffered |
||
| 438 | * |
||
| 439 | * @return static |
||
| 440 | * |
||
| 441 | * @see http://schema.org/itemOffered |
||
| 442 | */ |
||
| 443 | public function itemOffered($itemOffered) |
||
| 447 | |||
| 448 | /** |
||
| 449 | * The Manufacturer Part Number (MPN) of the product, or the product to |
||
| 450 | * which the offer refers. |
||
| 451 | * |
||
| 452 | * @param string|string[] $mpn |
||
| 453 | * |
||
| 454 | * @return static |
||
| 455 | * |
||
| 456 | * @see http://schema.org/mpn |
||
| 457 | */ |
||
| 458 | public function mpn($mpn) |
||
| 462 | |||
| 463 | /** |
||
| 464 | * The offer price of a product, or of a price component when attached to |
||
| 465 | * PriceSpecification and its subtypes. |
||
| 466 | * |
||
| 467 | * Usage guidelines: |
||
| 468 | * |
||
| 469 | * * Use the [[priceCurrency]] property (with standard formats: [ISO 4217 |
||
| 470 | * currency format](http://en.wikipedia.org/wiki/ISO_4217) e.g. "USD"; |
||
| 471 | * [Ticker symbol](https://en.wikipedia.org/wiki/List_of_cryptocurrencies) |
||
| 472 | * for cryptocurrencies e.g. "BTC"; well known names for [Local Exchange |
||
| 473 | * Tradings |
||
| 474 | * Systems](https://en.wikipedia.org/wiki/Local_exchange_trading_system) |
||
| 475 | * (LETS) and other currency types e.g. "Ithaca HOUR") instead of including |
||
| 476 | * [ambiguous |
||
| 477 | * symbols](http://en.wikipedia.org/wiki/Dollar_sign#Currencies_that_use_the_dollar_or_peso_sign) |
||
| 478 | * such as '$' in the value. |
||
| 479 | * * Use '.' (Unicode 'FULL STOP' (U+002E)) rather than ',' to indicate a |
||
| 480 | * decimal point. Avoid using these symbols as a readability separator. |
||
| 481 | * * Note that both |
||
| 482 | * [RDFa](http://www.w3.org/TR/xhtml-rdfa-primer/#using-the-content-attribute) |
||
| 483 | * and Microdata syntax allow the use of a "content=" attribute for |
||
| 484 | * publishing simple machine-readable values alongside more human-friendly |
||
| 485 | * formatting. |
||
| 486 | * * Use values from 0123456789 (Unicode 'DIGIT ZERO' (U+0030) to 'DIGIT |
||
| 487 | * NINE' (U+0039)) rather than superficially similiar Unicode symbols. |
||
| 488 | * |
||
| 489 | * @param float|float[]|int|int[]|string|string[] $price |
||
| 490 | * |
||
| 491 | * @return static |
||
| 492 | * |
||
| 493 | * @see http://schema.org/price |
||
| 494 | */ |
||
| 495 | public function price($price) |
||
| 499 | |||
| 500 | /** |
||
| 501 | * The currency of the price, or a price component when attached to |
||
| 502 | * [[PriceSpecification]] and its subtypes. |
||
| 503 | * |
||
| 504 | * Use standard formats: [ISO 4217 currency |
||
| 505 | * format](http://en.wikipedia.org/wiki/ISO_4217) e.g. "USD"; [Ticker |
||
| 506 | * symbol](https://en.wikipedia.org/wiki/List_of_cryptocurrencies) for |
||
| 507 | * cryptocurrencies e.g. "BTC"; well known names for [Local Exchange |
||
| 508 | * Tradings |
||
| 509 | * Systems](https://en.wikipedia.org/wiki/Local_exchange_trading_system) |
||
| 510 | * (LETS) and other currency types e.g. "Ithaca HOUR". |
||
| 511 | * |
||
| 512 | * @param string|string[] $priceCurrency |
||
| 513 | * |
||
| 514 | * @return static |
||
| 515 | * |
||
| 516 | * @see http://schema.org/priceCurrency |
||
| 517 | */ |
||
| 518 | public function priceCurrency($priceCurrency) |
||
| 522 | |||
| 523 | /** |
||
| 524 | * One or more detailed price specifications, indicating the unit price and |
||
| 525 | * delivery or payment charges. |
||
| 526 | * |
||
| 527 | * @param PriceSpecification|PriceSpecification[] $priceSpecification |
||
| 528 | * |
||
| 529 | * @return static |
||
| 530 | * |
||
| 531 | * @see http://schema.org/priceSpecification |
||
| 532 | */ |
||
| 533 | public function priceSpecification($priceSpecification) |
||
| 537 | |||
| 538 | /** |
||
| 539 | * The date after which the price is no longer available. |
||
| 540 | * |
||
| 541 | * @param \DateTimeInterface|\DateTimeInterface[] $priceValidUntil |
||
| 542 | * |
||
| 543 | * @return static |
||
| 544 | * |
||
| 545 | * @see http://schema.org/priceValidUntil |
||
| 546 | */ |
||
| 547 | public function priceValidUntil($priceValidUntil) |
||
| 551 | |||
| 552 | /** |
||
| 553 | * A review of the item. |
||
| 554 | * |
||
| 555 | * @param Review|Review[] $review |
||
| 556 | * |
||
| 557 | * @return static |
||
| 558 | * |
||
| 559 | * @see http://schema.org/review |
||
| 560 | */ |
||
| 561 | public function review($review) |
||
| 565 | |||
| 566 | /** |
||
| 567 | * Review of the item. |
||
| 568 | * |
||
| 569 | * @param Review|Review[] $reviews |
||
| 570 | * |
||
| 571 | * @return static |
||
| 572 | * |
||
| 573 | * @see http://schema.org/reviews |
||
| 574 | */ |
||
| 575 | public function reviews($reviews) |
||
| 579 | |||
| 580 | /** |
||
| 581 | * An entity which offers (sells / leases / lends / loans) the services / |
||
| 582 | * goods. A seller may also be a provider. |
||
| 583 | * |
||
| 584 | * @param Organization|Organization[]|Person|Person[] $seller |
||
| 585 | * |
||
| 586 | * @return static |
||
| 587 | * |
||
| 588 | * @see http://schema.org/seller |
||
| 589 | */ |
||
| 590 | public function seller($seller) |
||
| 594 | |||
| 595 | /** |
||
| 596 | * The serial number or any alphanumeric identifier of a particular product. |
||
| 597 | * When attached to an offer, it is a shortcut for the serial number of the |
||
| 598 | * product included in the offer. |
||
| 599 | * |
||
| 600 | * @param string|string[] $serialNumber |
||
| 601 | * |
||
| 602 | * @return static |
||
| 603 | * |
||
| 604 | * @see http://schema.org/serialNumber |
||
| 605 | */ |
||
| 606 | public function serialNumber($serialNumber) |
||
| 610 | |||
| 611 | /** |
||
| 612 | * The Stock Keeping Unit (SKU), i.e. a merchant-specific identifier for a |
||
| 613 | * product or service, or the product to which the offer refers. |
||
| 614 | * |
||
| 615 | * @param string|string[] $sku |
||
| 616 | * |
||
| 617 | * @return static |
||
| 618 | * |
||
| 619 | * @see http://schema.org/sku |
||
| 620 | */ |
||
| 621 | public function sku($sku) |
||
| 625 | |||
| 626 | /** |
||
| 627 | * The date when the item becomes valid. |
||
| 628 | * |
||
| 629 | * @param \DateTimeInterface|\DateTimeInterface[] $validFrom |
||
| 630 | * |
||
| 631 | * @return static |
||
| 632 | * |
||
| 633 | * @see http://schema.org/validFrom |
||
| 634 | */ |
||
| 635 | public function validFrom($validFrom) |
||
| 639 | |||
| 640 | /** |
||
| 641 | * The date after when the item is not valid. For example the end of an |
||
| 642 | * offer, salary period, or a period of opening hours. |
||
| 643 | * |
||
| 644 | * @param \DateTimeInterface|\DateTimeInterface[] $validThrough |
||
| 645 | * |
||
| 646 | * @return static |
||
| 647 | * |
||
| 648 | * @see http://schema.org/validThrough |
||
| 649 | */ |
||
| 650 | public function validThrough($validThrough) |
||
| 654 | |||
| 655 | /** |
||
| 656 | * The warranty promise(s) included in the offer. |
||
| 657 | * |
||
| 658 | * @param WarrantyPromise|WarrantyPromise[] $warranty |
||
| 659 | * |
||
| 660 | * @return static |
||
| 661 | * |
||
| 662 | * @see http://schema.org/warranty |
||
| 663 | */ |
||
| 664 | public function warranty($warranty) |
||
| 668 | |||
| 669 | } |
||
| 670 |