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 OrderResponse 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 OrderResponse, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 33 | class OrderResponse implements IOrderResponse |
||
| 34 | { |
||
| 35 | use TPayload, TOrderDetailItemContainer, TFeeContainer, TItemRelationshipContainer, TShipmentContainer, TCustomAttributeContainer, TTemplateContainer, TExchangeOrderContainer, TChargeGroupContainer; |
||
| 36 | |||
| 37 | /** @var string */ |
||
| 38 | protected $customerOrderId; |
||
| 39 | /** @var string */ |
||
| 40 | protected $levelOfService; |
||
| 41 | /** @var bool */ |
||
| 42 | protected $hasChainedLines; |
||
| 43 | /** @var bool */ |
||
| 44 | protected $hasDerivedChild; |
||
| 45 | /** @var string */ |
||
| 46 | protected $sourceId; |
||
| 47 | /** @var string */ |
||
| 48 | protected $sourceIdType; |
||
| 49 | /** @var IOrderDetailCustomer */ |
||
| 50 | protected $customer; |
||
| 51 | /** @var DateTime */ |
||
| 52 | protected $createTime; |
||
| 53 | /** @var IOrderDetailShipping */ |
||
| 54 | protected $shipping; |
||
| 55 | /** @var IOrderDetailPayment */ |
||
| 56 | protected $payment; |
||
| 57 | /** @var string */ |
||
| 58 | protected $shopRunnerMessage; |
||
| 59 | /** @var string */ |
||
| 60 | protected $currency; |
||
| 61 | /** @var IAssociate */ |
||
| 62 | protected $associate; |
||
| 63 | /** @var ITaxHeader */ |
||
| 64 | protected $taxHeader; |
||
| 65 | /** @var string */ |
||
| 66 | protected $printedCatalogCode; |
||
| 67 | /** @var string */ |
||
| 68 | protected $locale; |
||
| 69 | /** @var string */ |
||
| 70 | protected $dashboardRepId; |
||
| 71 | /** @var string */ |
||
| 72 | protected $orderSource; |
||
| 73 | /** @var string */ |
||
| 74 | protected $orderSourceType; |
||
| 75 | /** @var string */ |
||
| 76 | protected $status; |
||
| 77 | /** @var string */ |
||
| 78 | protected $orderHistoryUrl; |
||
| 79 | /** @var bool */ |
||
| 80 | protected $vatInclusivePricing; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @param IValidatorIterator |
||
| 84 | * @param ISchemaValidator |
||
| 85 | * @param IPayloadMap |
||
| 86 | * @param LoggerInterface |
||
| 87 | * @param IPayload |
||
| 88 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
||
| 89 | */ |
||
| 90 | public function __construct( |
||
| 91 | IValidatorIterator $validators, |
||
| 92 | ISchemaValidator $schemaValidator, |
||
| 93 | IPayloadMap $payloadMap, |
||
| 94 | LoggerInterface $logger, |
||
| 95 | IPayload $parentPayload = null |
||
| 96 | ) { |
||
| 97 | $this->logger = $logger; |
||
|
|
|||
| 98 | $this->validators = $validators; |
||
| 99 | $this->schemaValidator = $schemaValidator; |
||
| 100 | $this->parentPayload = $parentPayload; |
||
| 101 | $this->payloadMap = $payloadMap; |
||
| 102 | $this->payloadFactory = $this->getNewPayloadFactory(); |
||
| 103 | |||
| 104 | $this->initExtractPaths() |
||
| 105 | ->initOptionalExtractPaths() |
||
| 106 | ->initDatetimeExtractPaths() |
||
| 107 | ->initSubPayloadExtractPaths() |
||
| 108 | ->initSubPayloadProperties(); |
||
| 109 | } |
||
| 110 | |||
| 111 | /** |
||
| 112 | * Initialize the protected class property array self::extractionPaths with xpath |
||
| 113 | * key/value pairs. |
||
| 114 | * |
||
| 115 | * @return self |
||
| 116 | */ |
||
| 117 | protected function initExtractPaths() |
||
| 118 | { |
||
| 119 | $this->extractionPaths = [ |
||
| 120 | 'currency' => 'string(x:Currency)', |
||
| 121 | ]; |
||
| 122 | return $this; |
||
| 123 | } |
||
| 124 | |||
| 125 | /** |
||
| 126 | * Initialize the protected class property array self::optionalExtractionPaths with xpath |
||
| 127 | * key/value pairs. |
||
| 128 | * |
||
| 129 | * @return self |
||
| 130 | */ |
||
| 131 | protected function initOptionalExtractPaths() |
||
| 132 | { |
||
| 133 | $this->optionalExtractionPaths = [ |
||
| 134 | 'customerOrderId' => '@customerOrderId', |
||
| 135 | 'levelOfService' => '@levelOfService', |
||
| 136 | 'hasChainedLines' => '@hasChainedLines', |
||
| 137 | 'hasDerivedChild' => '@hasDerivedChild', |
||
| 138 | 'sourceId' => 'x:SourceId', |
||
| 139 | 'sourceIdType' => 'x:SourceId/@type', |
||
| 140 | 'shopRunnerMessage' => 'x:ShopRunnerMessage', |
||
| 141 | 'printedCatalogCode' => 'x:PrintedCatalogCode', |
||
| 142 | 'locale' => 'x:Locale', |
||
| 143 | 'dashboardRepId' => 'x:DashboardRepId', |
||
| 144 | 'orderSource' => 'x:OrderSource', |
||
| 145 | 'orderSourceType' => 'x:OrderSource/@type', |
||
| 146 | 'status' => 'x:Status', |
||
| 147 | 'orderHistoryUrl' => 'x:OrderHistoryUrl', |
||
| 148 | 'vatInclusivePricing' => 'x:VATInclusivePricing', |
||
| 149 | ]; |
||
| 150 | return $this; |
||
| 151 | } |
||
| 152 | |||
| 153 | /** |
||
| 154 | * Initialize the protected class property array self::subpayloadExtractionPaths with xpath |
||
| 155 | * key/value pairs. |
||
| 156 | * |
||
| 157 | * @return self |
||
| 158 | */ |
||
| 159 | protected function initSubPayloadExtractPaths() |
||
| 160 | { |
||
| 161 | $this->subpayloadExtractionPaths = [ |
||
| 162 | 'customer' => 'x:Customer', |
||
| 163 | 'orderItems' => 'x:OrderItems', |
||
| 164 | 'shipping' => 'x:Shipping', |
||
| 165 | 'payment' => 'x:Payment', |
||
| 166 | 'fees' => 'x:Fees', |
||
| 167 | 'associate' => 'x:Associate', |
||
| 168 | 'taxHeader' => 'x:TaxHeader', |
||
| 169 | 'itemRelationships' => 'x:Relationships', |
||
| 170 | 'shipments' => 'x:Shipments', |
||
| 171 | 'customAttributes' => 'x:CustomAttributes', |
||
| 172 | 'templates' => 'x:Templates', |
||
| 173 | 'exchangeOrders' => 'x:ExchangeOrders', |
||
| 174 | 'chargeGroups' => 'x:ChargeGroups', |
||
| 175 | ]; |
||
| 176 | return $this; |
||
| 177 | } |
||
| 178 | |||
| 179 | /** |
||
| 180 | * Initialize the protected class property array self::datetimeExtractionPaths with xpath |
||
| 181 | * key/value pairs. |
||
| 182 | * |
||
| 183 | * @return self |
||
| 184 | */ |
||
| 185 | protected function initDatetimeExtractPaths() |
||
| 186 | { |
||
| 187 | $this->datetimeExtractionPaths = [ |
||
| 188 | 'createTime' => 'string(x:CreateTime)', |
||
| 189 | ]; |
||
| 190 | return $this; |
||
| 191 | } |
||
| 192 | |||
| 193 | /** |
||
| 194 | * Initialize any sub-payload class properties with their concrete instance. |
||
| 195 | * |
||
| 196 | * @return self |
||
| 197 | */ |
||
| 198 | protected function initSubPayloadProperties() |
||
| 199 | { |
||
| 200 | $this->setCustomer($this->buildPayloadForInterface( |
||
| 201 | static::CUSTOMER_INTERFACE |
||
| 202 | )); |
||
| 203 | $this->setOrderDetailItems($this->buildPayloadForInterface( |
||
| 204 | static::ORDER_ITEM_ITERABLE_INTERFACE |
||
| 205 | )); |
||
| 206 | $this->setShipping($this->buildPayloadForInterface( |
||
| 207 | static::SHIPPING_INTERFACE |
||
| 208 | )); |
||
| 209 | $this->setPayment($this->buildPayloadForInterface( |
||
| 210 | static::PAYMENT_INTERFACE |
||
| 211 | )); |
||
| 212 | $this->setFees($this->buildPayloadForInterface( |
||
| 213 | static::FEE_ITERABLE_INTERFACE |
||
| 214 | )); |
||
| 215 | $this->setAssociate($this->buildPayloadForInterface( |
||
| 216 | static::ASSOCIATE_INTERFACE |
||
| 217 | )); |
||
| 218 | $this->setTaxHeader($this->buildPayloadForInterface( |
||
| 219 | static::TAX_HEADER_INTERFACE |
||
| 220 | )); |
||
| 221 | $this->setItemRelationships($this->buildPayloadForInterface( |
||
| 222 | static::ITEM_RELATIONSHIP_ITERABLE_INTERFACE |
||
| 223 | )); |
||
| 224 | $this->setShipments($this->buildPayloadForInterface( |
||
| 225 | static::SHIPMENT_ITERABLE_INTERFACE |
||
| 226 | )); |
||
| 227 | $this->setCustomAttributes($this->buildPayloadForInterface( |
||
| 228 | static::CUSTOM_ATTRIBUTE_ITERABLE_INTERFACE |
||
| 229 | )); |
||
| 230 | $this->setTemplates($this->buildPayloadForInterface( |
||
| 231 | static::TEMPLATE_ITERABLE_INTERFACE |
||
| 232 | )); |
||
| 233 | $this->setExchangeOrders($this->buildPayloadForInterface( |
||
| 234 | static::EXCHANGE_ORDER_ITERABLE_INTERFACE |
||
| 235 | )); |
||
| 236 | $this->setChargeGroups($this->buildPayloadForInterface( |
||
| 237 | self::CHARGE_GROUP_ITERABLE_INTERFACE |
||
| 238 | )); |
||
| 239 | return $this; |
||
| 240 | } |
||
| 241 | |||
| 242 | /** |
||
| 243 | * @see IOrderResponse::getCustomerOrderId() |
||
| 244 | */ |
||
| 245 | public function getCustomerOrderId() |
||
| 249 | |||
| 250 | /** |
||
| 251 | * @see IOrderResponse::setCustomerOrderId() |
||
| 252 | * @codeCoverageIgnore |
||
| 253 | */ |
||
| 254 | public function setCustomerOrderId($customerOrderId) |
||
| 255 | { |
||
| 256 | $this->customerOrderId = $customerOrderId; |
||
| 257 | return $this; |
||
| 258 | } |
||
| 259 | |||
| 260 | /** |
||
| 261 | * @see IOrderResponse::getLevelOfService() |
||
| 262 | */ |
||
| 263 | public function getLevelOfService() |
||
| 267 | |||
| 268 | /** |
||
| 269 | * @see IOrderResponse::setLevelOfService() |
||
| 270 | * @codeCoverageIgnore |
||
| 271 | */ |
||
| 272 | public function setLevelOfService($levelOfService) |
||
| 273 | { |
||
| 274 | $this->levelOfService = $levelOfService; |
||
| 275 | return $this; |
||
| 276 | } |
||
| 277 | |||
| 278 | /** |
||
| 279 | * @see IOrderResponse::getHasChainedLines() |
||
| 280 | */ |
||
| 281 | public function getHasChainedLines() |
||
| 285 | |||
| 286 | /** |
||
| 287 | * @see IOrderResponse::setHasChainedLines() |
||
| 288 | * @codeCoverageIgnore |
||
| 289 | */ |
||
| 290 | public function setHasChainedLines($hasChainedLines) |
||
| 291 | { |
||
| 292 | $this->hasChainedLines = $hasChainedLines; |
||
| 293 | return $this; |
||
| 294 | } |
||
| 295 | |||
| 296 | /** |
||
| 297 | * @see IOrderResponse::getHasDerivedChild() |
||
| 298 | */ |
||
| 299 | public function getHasDerivedChild() |
||
| 303 | |||
| 304 | /** |
||
| 305 | * @see IOrderResponse::setHasDerivedChild() |
||
| 306 | * @codeCoverageIgnore |
||
| 307 | */ |
||
| 308 | public function setHasDerivedChild($hasDerivedChild) |
||
| 309 | { |
||
| 310 | $this->hasDerivedChild = $hasDerivedChild; |
||
| 311 | return $this; |
||
| 312 | } |
||
| 313 | |||
| 314 | /** |
||
| 315 | * @see IOrderResponse::getSourceId() |
||
| 316 | */ |
||
| 317 | public function getSourceId() |
||
| 321 | |||
| 322 | /** |
||
| 323 | * @see IOrderResponse::setSourceId() |
||
| 324 | * @codeCoverageIgnore |
||
| 325 | */ |
||
| 326 | public function setSourceId($sourceId) |
||
| 327 | { |
||
| 328 | $this->sourceId = $sourceId; |
||
| 329 | return $this; |
||
| 330 | } |
||
| 331 | |||
| 332 | /** |
||
| 333 | * @see IOrderResponse::getSourceIdType() |
||
| 334 | */ |
||
| 335 | public function getSourceIdType() |
||
| 339 | |||
| 340 | /** |
||
| 341 | * @see IOrderResponse::setSourceIdType() |
||
| 342 | * @codeCoverageIgnore |
||
| 343 | */ |
||
| 344 | public function setSourceIdType($sourceIdType) |
||
| 345 | { |
||
| 346 | $this->sourceIdType = $sourceIdType; |
||
| 347 | return $this; |
||
| 348 | } |
||
| 349 | |||
| 350 | /** |
||
| 351 | * @see IOrderResponse::getCustomer() |
||
| 352 | */ |
||
| 353 | public function getCustomer() |
||
| 357 | |||
| 358 | /** |
||
| 359 | * @see IOrderResponse::setCustomer() |
||
| 360 | * @codeCoverageIgnore |
||
| 361 | */ |
||
| 362 | public function setCustomer(IOrderDetailCustomer $customer) |
||
| 363 | { |
||
| 364 | $this->customer = $customer; |
||
| 365 | return $this; |
||
| 366 | } |
||
| 367 | |||
| 368 | /** |
||
| 369 | * @see IOrderResponse::getCreateTime() |
||
| 370 | */ |
||
| 371 | public function getCreateTime() |
||
| 375 | |||
| 376 | /** |
||
| 377 | * @see IOrderResponse::setCreateTime() |
||
| 378 | * @codeCoverageIgnore |
||
| 379 | */ |
||
| 380 | public function setCreateTime(DateTime $createTime) |
||
| 381 | { |
||
| 382 | $this->createTime = $createTime; |
||
| 383 | return $this; |
||
| 384 | } |
||
| 385 | |||
| 386 | /** |
||
| 387 | * @see IOrderResponse::getShipping() |
||
| 388 | */ |
||
| 389 | public function getShipping() |
||
| 393 | |||
| 394 | /** |
||
| 395 | * @see IOrderResponse::setShipping() |
||
| 396 | * @codeCoverageIgnore |
||
| 397 | */ |
||
| 398 | public function setShipping(IOrderDetailShipping $shipping) |
||
| 399 | { |
||
| 400 | $this->shipping = $shipping; |
||
| 401 | return $this; |
||
| 402 | } |
||
| 403 | |||
| 404 | /** |
||
| 405 | * @see IOrderResponse::getPayment() |
||
| 406 | */ |
||
| 407 | public function getPayment() |
||
| 411 | |||
| 412 | /** |
||
| 413 | * @see IOrderResponse::setPayment() |
||
| 414 | * @codeCoverageIgnore |
||
| 415 | */ |
||
| 416 | public function setPayment(IOrderDetailPayment $payment) |
||
| 417 | { |
||
| 418 | $this->payment = $payment; |
||
| 419 | return $this; |
||
| 420 | } |
||
| 421 | |||
| 422 | /** |
||
| 423 | * @see IOrderResponse::getShopRunnerMessage() |
||
| 424 | */ |
||
| 425 | public function getShopRunnerMessage() |
||
| 429 | |||
| 430 | /** |
||
| 431 | * @see IOrderResponse::setShopRunnerMessage() |
||
| 432 | * @codeCoverageIgnore |
||
| 433 | */ |
||
| 434 | public function setShopRunnerMessage($shopRunnerMessage) |
||
| 435 | { |
||
| 436 | $this->shopRunnerMessage = $shopRunnerMessage; |
||
| 437 | return $this; |
||
| 438 | } |
||
| 439 | |||
| 440 | /** |
||
| 441 | * @see IOrderResponse::getCurrency() |
||
| 442 | */ |
||
| 443 | public function getCurrency() |
||
| 447 | |||
| 448 | /** |
||
| 449 | * @see IOrderResponse::setCurrency() |
||
| 450 | * @codeCoverageIgnore |
||
| 451 | */ |
||
| 452 | public function setCurrency($currency) |
||
| 453 | { |
||
| 454 | $this->currency = $currency; |
||
| 455 | return $this; |
||
| 456 | } |
||
| 457 | |||
| 458 | /** |
||
| 459 | * @see IOrderResponse::getAssociate() |
||
| 460 | */ |
||
| 461 | public function getAssociate() |
||
| 465 | |||
| 466 | /** |
||
| 467 | * @see IOrderResponse::setAssociate() |
||
| 468 | * @codeCoverageIgnore |
||
| 469 | */ |
||
| 470 | public function setAssociate(IAssociate $associate) |
||
| 471 | { |
||
| 472 | $this->associate = $associate; |
||
| 473 | return $this; |
||
| 474 | } |
||
| 475 | |||
| 476 | /** |
||
| 477 | * @see IOrderResponse::getTaxHeader() |
||
| 478 | */ |
||
| 479 | public function getTaxHeader() |
||
| 483 | |||
| 484 | /** |
||
| 485 | * @see IOrderResponse::setTaxHeader() |
||
| 486 | * @codeCoverageIgnore |
||
| 487 | */ |
||
| 488 | public function setTaxHeader(ITaxHeader $taxHeader) |
||
| 489 | { |
||
| 490 | $this->taxHeader = $taxHeader; |
||
| 491 | return $this; |
||
| 492 | } |
||
| 493 | |||
| 494 | /** |
||
| 495 | * @see IOrderResponse::getPrintedCatalogCode() |
||
| 496 | */ |
||
| 497 | public function getPrintedCatalogCode() |
||
| 501 | |||
| 502 | /** |
||
| 503 | * @see IOrderResponse::setPrintedCatalogCode() |
||
| 504 | * @codeCoverageIgnore |
||
| 505 | */ |
||
| 506 | public function setPrintedCatalogCode($printedCatalogCode) |
||
| 507 | { |
||
| 508 | $this->printedCatalogCode = $printedCatalogCode; |
||
| 509 | return $this; |
||
| 510 | } |
||
| 511 | |||
| 512 | /** |
||
| 513 | * @see IOrderResponse::getLocale() |
||
| 514 | */ |
||
| 515 | public function getLocale() |
||
| 519 | |||
| 520 | /** |
||
| 521 | * @see IOrderResponse::setLocale() |
||
| 522 | * @codeCoverageIgnore |
||
| 523 | */ |
||
| 524 | public function setLocale($locale) |
||
| 525 | { |
||
| 526 | $this->locale = $locale; |
||
| 527 | return $this; |
||
| 528 | } |
||
| 529 | |||
| 530 | /** |
||
| 531 | * @see IOrderResponse::getDashboardRepId() |
||
| 532 | */ |
||
| 533 | public function getDashboardRepId() |
||
| 537 | |||
| 538 | /** |
||
| 539 | * @see IOrderResponse::setDashboardRepId() |
||
| 540 | * @codeCoverageIgnore |
||
| 541 | */ |
||
| 542 | public function setDashboardRepId($dashboardRepId) |
||
| 543 | { |
||
| 544 | $this->dashboardRepId = $dashboardRepId; |
||
| 545 | return $this; |
||
| 546 | } |
||
| 547 | |||
| 548 | /** |
||
| 549 | * @see IOrderResponse::getOrderSource() |
||
| 550 | */ |
||
| 551 | public function getOrderSource() |
||
| 555 | |||
| 556 | /** |
||
| 557 | * @see IOrderResponse::setOrderSource() |
||
| 558 | * @codeCoverageIgnore |
||
| 559 | */ |
||
| 560 | public function setOrderSource($orderSource) |
||
| 561 | { |
||
| 562 | $this->orderSource = $orderSource; |
||
| 563 | return $this; |
||
| 564 | } |
||
| 565 | |||
| 566 | /** |
||
| 567 | * @see IOrderResponse::getOrderSourceType() |
||
| 568 | */ |
||
| 569 | public function getOrderSourceType() |
||
| 573 | |||
| 574 | /** |
||
| 575 | * @see IOrderResponse::setOrderSourceType() |
||
| 576 | * @codeCoverageIgnore |
||
| 577 | */ |
||
| 578 | public function setOrderSourceType($orderSourceType) |
||
| 579 | { |
||
| 580 | $this->orderSourceType = $orderSourceType; |
||
| 581 | return $this; |
||
| 582 | } |
||
| 583 | |||
| 584 | /** |
||
| 585 | * @see IOrderResponse::getStatus() |
||
| 586 | */ |
||
| 587 | public function getStatus() |
||
| 591 | |||
| 592 | /** |
||
| 593 | * @see IOrderResponse::setStatus() |
||
| 594 | * @codeCoverageIgnore |
||
| 595 | */ |
||
| 596 | public function setStatus($status) |
||
| 597 | { |
||
| 598 | $this->status = $status; |
||
| 599 | return $this; |
||
| 600 | } |
||
| 601 | |||
| 602 | /** |
||
| 603 | * @see IOrderResponse::getOrderHistoryUrl() |
||
| 604 | */ |
||
| 605 | public function getOrderHistoryUrl() |
||
| 609 | |||
| 610 | /** |
||
| 611 | * @see IOrderResponse::setOrderHistoryUrl() |
||
| 612 | * @codeCoverageIgnore |
||
| 613 | */ |
||
| 614 | public function setOrderHistoryUrl($orderHistoryUrl) |
||
| 615 | { |
||
| 616 | $this->orderHistoryUrl = $orderHistoryUrl; |
||
| 617 | return $this; |
||
| 618 | } |
||
| 619 | |||
| 620 | /** |
||
| 621 | * @see IOrderResponse::getVatInclusivePricing() |
||
| 622 | */ |
||
| 623 | public function getVatInclusivePricing() |
||
| 627 | |||
| 628 | /** |
||
| 629 | * @see IOrderResponse::setVatInclusivePricing() |
||
| 630 | * @codeCoverageIgnore |
||
| 631 | */ |
||
| 632 | public function setVatInclusivePricing($vatInclusivePricing) |
||
| 633 | { |
||
| 634 | $this->vatInclusivePricing = $vatInclusivePricing; |
||
| 635 | return $this; |
||
| 636 | } |
||
| 637 | |||
| 638 | /** |
||
| 639 | * @see TPayload::serializeContents() |
||
| 640 | */ |
||
| 641 | protected function serializeContents() |
||
| 642 | { |
||
| 643 | return $this->serializeSourceIdValue('SourceId', $this->getSourceId()) |
||
| 644 | . $this->getCustomer()->serialize() |
||
| 645 | . $this->serializeOptionalDateValue('CreateTime', 'c', $this->getCreateTime()) |
||
| 646 | . $this->getOrderDetailItems()->serialize() |
||
| 647 | . $this->getShipping()->serialize() |
||
| 648 | . $this->getPayment()->serialize() |
||
| 649 | . $this->getChargeGroups()->serialize() |
||
| 650 | . $this->getFees()->serialize() |
||
| 651 | . $this->serializeOptionalXmlEncodedValue('ShopRunnerMessage', $this->getShopRunnerMessage()) |
||
| 652 | . $this->serializeRequiredValue('Currency', $this->xmlEncode($this->getCurrency())) |
||
| 653 | . $this->getAssociate()->serialize() |
||
| 654 | . $this->getTaxHeader()->serialize() |
||
| 655 | . $this->serializeOptionalXmlEncodedValue('PrintedCatalogCode', $this->getPrintedCatalogCode()) |
||
| 656 | . $this->serializeOptionalXmlEncodedValue('Locale', $this->getLocale()) |
||
| 657 | . $this->getItemRelationships()->serialize() |
||
| 658 | . $this->getShipments()->serialize() |
||
| 659 | . $this->serializeOptionalXmlEncodedValue('DashboardRepId', $this->getDashboardRepId()) |
||
| 660 | . $this->serializeOrderSourceValue('OrderSource', $this->getOrderSource()) |
||
| 661 | . $this->serializeOptionalXmlEncodedValue('Status', $this->getStatus()) |
||
| 662 | . $this->getCustomAttributes()->serialize() |
||
| 663 | . $this->getTemplates()->serialize() |
||
| 664 | . $this->serializeOrderHistoryUrlValue('OrderHistoryUrl', $this->getOrderHistoryUrl()) |
||
| 665 | . $this->serializeOptionalXmlEncodedValue('VATInclusivePricing', $this->getVatInclusivePricing()) |
||
| 666 | . $this->getExchangeOrders()->serialize(); |
||
| 667 | } |
||
| 668 | |||
| 669 | /** |
||
| 670 | * Serialize order history URL XML node. |
||
| 671 | * |
||
| 672 | * @param string |
||
| 673 | * @param string |
||
| 674 | * @return string | null |
||
| 675 | */ |
||
| 676 | protected function serializeOrderHistoryUrlValue($nodeName, $value) |
||
| 677 | { |
||
| 678 | $orderHistoryUrl = $this->getOrderHistoryUrl(); |
||
| 679 | return $orderHistoryUrl |
||
| 680 | ? $this->serializeOptionalXmlEncodedValue('OrderHistoryUrl', $orderHistoryUrl) : null; |
||
| 681 | } |
||
| 682 | |||
| 683 | /** |
||
| 684 | * @see TPayload::getRootNodeName() |
||
| 685 | */ |
||
| 686 | protected function getRootNodeName() |
||
| 690 | |||
| 691 | /** |
||
| 692 | * @see TPayload::getXmlNamespace() |
||
| 693 | */ |
||
| 694 | protected function getXmlNamespace() |
||
| 698 | |||
| 699 | /** |
||
| 700 | * @see TPayload::getRootAttributes() |
||
| 701 | */ |
||
| 702 | View Code Duplication | protected function getRootAttributes() |
|
| 703 | { |
||
| 704 | $customerOrderId = $this->getCustomerOrderId(); |
||
| 705 | $levelOfService = $this->getLevelOfService(); |
||
| 706 | $hasChainedLines = $this->getHasChainedLines(); |
||
| 707 | $hasDerivedChild = $this->getHasDerivedChild(); |
||
| 708 | return array_merge( |
||
| 709 | $customerOrderId ? ['customerOrderId' => $customerOrderId] : [], |
||
| 710 | $levelOfService ? ['levelOfService' => $levelOfService] : [], |
||
| 711 | !empty($hasChainedLines) ? ['hasChainedLines' => $hasChainedLines] : [], |
||
| 712 | !empty($hasDerivedChild) ? ['hasDerivedChild' => $hasDerivedChild] : [] |
||
| 713 | ); |
||
| 714 | } |
||
| 715 | |||
| 716 | /** |
||
| 717 | * Serialize the OrderSource XML node. |
||
| 718 | * |
||
| 719 | * @param string |
||
| 720 | * @param string |
||
| 721 | * @return string | null |
||
| 722 | */ |
||
| 723 | protected function serializeOrderSourceValue($nodeName, $value) |
||
| 724 | { |
||
| 725 | $typeAttribute = $this->serializeOptionalAttribute('type', $this->xmlEncode($this->getOrderSourceType())); |
||
| 726 | return $value |
||
| 727 | ? sprintf('<%s %s>%s</%1$s>', $nodeName, $typeAttribute, $this->xmlEncode($value)) : null; |
||
| 728 | } |
||
| 729 | |||
| 730 | /** |
||
| 731 | * Serialize the SourceId XML node. |
||
| 732 | * |
||
| 733 | * @param string |
||
| 734 | * @param string |
||
| 735 | * @return string | null |
||
| 736 | */ |
||
| 737 | protected function serializeSourceIdValue($nodeName, $value) |
||
| 743 | } |
||
| 744 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..