| Total Complexity | 88 |
| Total Lines | 1123 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like Order 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.
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 Order, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 27 | class Order implements OrderInterface |
||
| 28 | { |
||
| 29 | use OrderTraits; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @var int |
||
| 33 | * |
||
| 34 | * @ORM\Id |
||
| 35 | * @ORM\GeneratedValue |
||
| 36 | * @ORM\Column(type="integer") |
||
| 37 | **/ |
||
| 38 | protected $id; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * This is the order id in Dandomain |
||
| 42 | * |
||
| 43 | * @var int |
||
| 44 | * |
||
| 45 | * @ORM\Column(type="integer", unique=true) |
||
| 46 | */ |
||
| 47 | protected $externalId; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @var CustomerInterface|null |
||
| 51 | * |
||
| 52 | * @ORM\JoinColumn(onDelete="SET NULL") |
||
| 53 | * @ORM\ManyToOne(targetEntity="Customer", cascade={"persist", "remove"}) |
||
| 54 | */ |
||
| 55 | protected $customer; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @var DeliveryInterface|null |
||
| 59 | * |
||
| 60 | * @ORM\JoinColumn(onDelete="SET NULL") |
||
| 61 | * @ORM\ManyToOne(targetEntity="Delivery", cascade={"persist", "remove"}) |
||
| 62 | */ |
||
| 63 | protected $delivery; |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @var InvoiceInterface|null |
||
| 67 | * |
||
| 68 | * @ORM\JoinColumn(onDelete="SET NULL") |
||
| 69 | * @ORM\ManyToOne(targetEntity="Invoice", cascade={"persist", "remove"}) |
||
| 70 | */ |
||
| 71 | protected $invoice; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @var ArrayCollection|null |
||
| 75 | * |
||
| 76 | * @ORM\OneToMany(mappedBy="order", targetEntity="OrderLine", cascade={"persist", "remove"}) |
||
| 77 | */ |
||
| 78 | protected $orderLines; |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @var PaymentMethodInterface|null |
||
| 82 | * |
||
| 83 | * @ORM\JoinColumn(onDelete="SET NULL") |
||
| 84 | * @ORM\ManyToOne(targetEntity="PaymentMethod", cascade={"persist", "remove"}) |
||
| 85 | */ |
||
| 86 | protected $paymentMethod; |
||
| 87 | |||
| 88 | /** |
||
| 89 | * Because the fee can change on the payment method we have a field for here for the fee on this order |
||
| 90 | * |
||
| 91 | * @var integer|null |
||
| 92 | * |
||
| 93 | * @ORM\Column(type="integer", nullable=true) |
||
| 94 | */ |
||
| 95 | protected $paymentMethodFee; |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @var ShippingMethodInterface|null |
||
| 99 | * |
||
| 100 | * @ORM\JoinColumn(onDelete="SET NULL") |
||
| 101 | * @ORM\ManyToOne(targetEntity="ShippingMethod", cascade={"persist", "remove"}) |
||
| 102 | */ |
||
| 103 | protected $shippingMethod; |
||
| 104 | |||
| 105 | /** |
||
| 106 | * Because the fee can change on the shipping method we have a field for here for the fee on this order |
||
| 107 | * |
||
| 108 | * @var integer|null |
||
| 109 | * |
||
| 110 | * @ORM\Column(type="integer", nullable=true) |
||
| 111 | */ |
||
| 112 | protected $shippingMethodFee; |
||
| 113 | |||
| 114 | /** |
||
| 115 | * @var SiteInterface|null |
||
| 116 | * |
||
| 117 | * @ORM\JoinColumn(onDelete="SET NULL") |
||
| 118 | * @ORM\ManyToOne(targetEntity="Site", cascade={"persist", "remove"}) |
||
| 119 | */ |
||
| 120 | protected $site; |
||
| 121 | |||
| 122 | /** |
||
| 123 | * @var StateInterface|null |
||
| 124 | * |
||
| 125 | * @ORM\JoinColumn(onDelete="SET NULL") |
||
| 126 | * @ORM\ManyToOne(targetEntity="State", cascade={"persist", "remove"}) |
||
| 127 | */ |
||
| 128 | protected $state; |
||
| 129 | |||
| 130 | /** |
||
| 131 | * @var string|null |
||
| 132 | * |
||
| 133 | * @ORM\Column(nullable=true, type="text") |
||
| 134 | */ |
||
| 135 | protected $comment; |
||
| 136 | |||
| 137 | /** |
||
| 138 | * @var \DateTimeImmutable|null |
||
| 139 | * |
||
| 140 | * @ORM\Column(nullable=true, type="datetime_immutable") |
||
| 141 | */ |
||
| 142 | protected $createdDate; |
||
| 143 | |||
| 144 | /** |
||
| 145 | * @var string|null |
||
| 146 | * |
||
| 147 | * @ORM\Column(nullable=true, type="string", length=191) |
||
| 148 | */ |
||
| 149 | protected $creditNoteNumber; |
||
| 150 | |||
| 151 | /** |
||
| 152 | * @var string|null |
||
| 153 | * |
||
| 154 | * @ORM\Column(type="string", length=3, nullable=true) |
||
| 155 | */ |
||
| 156 | protected $currencyCode; |
||
| 157 | |||
| 158 | /** |
||
| 159 | * @var string|null |
||
| 160 | * |
||
| 161 | * @ORM\Column(nullable=true, type="text") |
||
| 162 | */ |
||
| 163 | protected $customerComment; |
||
| 164 | |||
| 165 | /** |
||
| 166 | * @var integer|null |
||
| 167 | * |
||
| 168 | * @ORM\Column(type="integer", nullable=true) |
||
| 169 | */ |
||
| 170 | protected $giftCertificateAmount; |
||
| 171 | |||
| 172 | /** |
||
| 173 | * @var string|null |
||
| 174 | * |
||
| 175 | * @ORM\Column(nullable=true, type="string", length=191) |
||
| 176 | */ |
||
| 177 | protected $giftCertificateNumber; |
||
| 178 | |||
| 179 | /** |
||
| 180 | * @var bool|null |
||
| 181 | * |
||
| 182 | * @ORM\Column(type="boolean", nullable=true) |
||
| 183 | */ |
||
| 184 | protected $incomplete; |
||
| 185 | |||
| 186 | /** |
||
| 187 | * @var string|null |
||
| 188 | * |
||
| 189 | * @ORM\Column(nullable=true, type="string", length=191) |
||
| 190 | */ |
||
| 191 | protected $ip; |
||
| 192 | |||
| 193 | /** |
||
| 194 | * @var bool|null |
||
| 195 | * |
||
| 196 | * @ORM\Column(type="boolean", nullable=true) |
||
| 197 | */ |
||
| 198 | protected $modified; |
||
| 199 | |||
| 200 | /** |
||
| 201 | * @var \DateTimeImmutable|null |
||
| 202 | * |
||
| 203 | * @ORM\Column(nullable=true, type="datetime_immutable") |
||
| 204 | */ |
||
| 205 | protected $modifiedDate; |
||
| 206 | |||
| 207 | /** |
||
| 208 | * @var string|null |
||
| 209 | * |
||
| 210 | * @ORM\Column(nullable=true, type="string", length=191) |
||
| 211 | */ |
||
| 212 | protected $referenceNumber; |
||
| 213 | |||
| 214 | /** |
||
| 215 | * @var string|null |
||
| 216 | * |
||
| 217 | * @ORM\Column(nullable=true, type="string", length=191) |
||
| 218 | */ |
||
| 219 | protected $referrer; |
||
| 220 | |||
| 221 | /** |
||
| 222 | * @var string|null |
||
| 223 | * |
||
| 224 | * @ORM\Column(nullable=true, type="string", length=191) |
||
| 225 | */ |
||
| 226 | protected $reservedField1; |
||
| 227 | |||
| 228 | /** |
||
| 229 | * @var string|null |
||
| 230 | * |
||
| 231 | * @ORM\Column(nullable=true, type="string", length=191) |
||
| 232 | */ |
||
| 233 | protected $reservedField2; |
||
| 234 | |||
| 235 | /** |
||
| 236 | * @var string|null |
||
| 237 | * |
||
| 238 | * @ORM\Column(nullable=true, type="string", length=191) |
||
| 239 | */ |
||
| 240 | protected $reservedField3; |
||
| 241 | |||
| 242 | /** |
||
| 243 | * @var string|null |
||
| 244 | * |
||
| 245 | * @ORM\Column(nullable=true, type="string", length=191) |
||
| 246 | */ |
||
| 247 | protected $reservedField4; |
||
| 248 | |||
| 249 | /** |
||
| 250 | * @var string|null |
||
| 251 | * |
||
| 252 | * @ORM\Column(nullable=true, type="string", length=191) |
||
| 253 | */ |
||
| 254 | protected $reservedField5; |
||
| 255 | |||
| 256 | /** |
||
| 257 | * @var int|null |
||
| 258 | * |
||
| 259 | * @ORM\Column(type="integer", nullable=true) |
||
| 260 | */ |
||
| 261 | protected $salesDiscount; |
||
| 262 | |||
| 263 | /** |
||
| 264 | * @var int|null |
||
| 265 | * |
||
| 266 | * @ORM\Column(type="integer", nullable=true) |
||
| 267 | */ |
||
| 268 | protected $totalPrice; |
||
| 269 | |||
| 270 | /** |
||
| 271 | * @var float|null |
||
| 272 | * |
||
| 273 | * @ORM\Column(nullable=true, type="decimal", precision=12, scale=2) |
||
| 274 | */ |
||
| 275 | protected $totalWeight; |
||
| 276 | |||
| 277 | /** |
||
| 278 | * @var string|null |
||
| 279 | * |
||
| 280 | * @ORM\Column(nullable=true, type="string", length=191) |
||
| 281 | */ |
||
| 282 | protected $trackingNumber; |
||
| 283 | |||
| 284 | /** |
||
| 285 | * @var int|null |
||
| 286 | * |
||
| 287 | * @ORM\Column(nullable=true, type="string", length=191) |
||
| 288 | */ |
||
| 289 | protected $transactionNumber; |
||
| 290 | |||
| 291 | /** |
||
| 292 | * @var float|null |
||
| 293 | * |
||
| 294 | * @ORM\Column(nullable=true, type="decimal", precision=5, scale=2) |
||
| 295 | */ |
||
| 296 | protected $vatPct; |
||
| 297 | |||
| 298 | /** |
||
| 299 | * @var string|null |
||
| 300 | * |
||
| 301 | * @ORM\Column(nullable=true, type="string", length=191) |
||
| 302 | */ |
||
| 303 | protected $vatRegNumber; |
||
| 304 | |||
| 305 | /** |
||
| 306 | * @var string|null |
||
| 307 | * |
||
| 308 | * @ORM\Column(nullable=true, type="text") |
||
| 309 | */ |
||
| 310 | protected $xmlParams; |
||
| 311 | |||
| 312 | public function __construct() |
||
| 313 | { |
||
| 314 | $this->orderLines = new ArrayCollection(); |
||
| 315 | } |
||
| 316 | |||
| 317 | /** |
||
| 318 | * Populates an order based on the response from the Dandomain API |
||
| 319 | * |
||
| 320 | * See the properties here: |
||
| 321 | * http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/OrderService/help/operations/GetOrder |
||
| 322 | * |
||
| 323 | * @param \stdClass|array $data |
||
| 324 | * @param bool $populateEmbedded |
||
| 325 | * @return OrderInterface |
||
| 326 | */ |
||
| 327 | public function populateFromApiResponse($data, $populateEmbedded) : OrderInterface |
||
| 328 | { |
||
| 329 | $data = DandomainFoundation\objectToArray($data); |
||
| 330 | |||
| 331 | // set currency because we use the currency to create Money objects |
||
| 332 | $this->setCurrencyCode($data['currencyCode']); |
||
| 333 | |||
| 334 | // set shortcuts for embedded objects |
||
| 335 | $orderLinesData = $data['orderLines'] ?? []; |
||
|
|
|||
| 336 | $paymentData = $data['paymentInfo'] ?? []; |
||
| 337 | $shippingData = $data['shippingInfo'] ?? []; |
||
| 338 | |||
| 339 | $createdDate = DateTimeImmutable::createFromJson($data['createdDate']); |
||
| 340 | $modifiedDate = DateTimeImmutable::createFromJson($data['modifiedDate']); |
||
| 341 | |||
| 342 | $giftCertificateAmount = $this->createMoneyFromFloat($data['giftCertificateAmount']); |
||
| 343 | $totalPrice = $this->createMoneyFromFloat($data['totalPrice']); |
||
| 344 | $salesDiscount = $this->createMoneyFromFloat($data['salesDiscount']); |
||
| 345 | $paymentMethodFee = $this->createMoneyFromFloat($paymentData['fee'] ?? 0.0); |
||
| 346 | $shippingMethodFee = $this->createMoneyFromFloat($shippingData['fee'] ?? 0.0); |
||
| 347 | |||
| 348 | $this |
||
| 349 | ->setExternalId($data['id']) |
||
| 350 | ->setComment($data['comment']) |
||
| 351 | ->setCreatedDate($createdDate) |
||
| 352 | ->setCustomerComment($data['customerComment']) |
||
| 353 | ->setGiftCertificateAmount($giftCertificateAmount) |
||
| 354 | ->setGiftCertificateNumber($data['giftCertificateNumber']) |
||
| 355 | ->setIncomplete($data['incomplete']) |
||
| 356 | ->setIp($data['ip']) |
||
| 357 | ->setModified($data['modified']) |
||
| 358 | ->setModifiedDate($modifiedDate) |
||
| 359 | ->setReferenceNumber($data['referenceNumber']) |
||
| 360 | ->setReferrer($data['referrer']) |
||
| 361 | ->setReservedField1($data['reservedField1']) |
||
| 362 | ->setReservedField2($data['reservedField2']) |
||
| 363 | ->setReservedField3($data['reservedField3']) |
||
| 364 | ->setReservedField4($data['reservedField4']) |
||
| 365 | ->setReservedField5($data['reservedField5']) |
||
| 366 | ->setSalesDiscount($salesDiscount) |
||
| 367 | ->setTotalPrice($totalPrice) |
||
| 368 | ->setTotalWeight($data['totalWeight']) |
||
| 369 | ->setTrackingNumber($data['trackingNumber']) |
||
| 370 | ->setTransactionNumber($data['transactionNumber']) |
||
| 371 | ->setVatPct($data['vatPct']) |
||
| 372 | ->setVatRegNumber($data['vatRegNumber']) |
||
| 373 | ->setXmlParams($data['xmlParams']) |
||
| 374 | ->setShippingMethodFee($shippingMethodFee) |
||
| 375 | ->setPaymentMethodFee($paymentMethodFee) |
||
| 376 | ; |
||
| 377 | |||
| 378 | if ($populateEmbedded) { |
||
| 379 | // populate customer |
||
| 380 | $customer = $this->getCustomer(); |
||
| 381 | if (!$customer) { |
||
| 382 | $customer = new Customer(); |
||
| 383 | $this->setCustomer($customer); |
||
| 384 | } |
||
| 385 | $customer->populateFromApiResponse($data['customerInfo']); |
||
| 386 | |||
| 387 | // populate delivery info |
||
| 388 | $delivery = $this->getDelivery(); |
||
| 389 | if (!$delivery) { |
||
| 390 | $delivery = new Delivery(); |
||
| 391 | $this->setDelivery($delivery); |
||
| 392 | } |
||
| 393 | $delivery->populateFromApiResponse($data['deliveryInfo']); |
||
| 394 | |||
| 395 | // populate invoice info |
||
| 396 | $invoice = $this->getInvoice(); |
||
| 397 | if (!$invoice) { |
||
| 398 | $invoice = new Invoice(); |
||
| 399 | $this->setInvoice($invoice); |
||
| 400 | } |
||
| 401 | $invoice->populateFromApiResponse($data['invoiceInfo']); |
||
| 402 | |||
| 403 | // populate payment info |
||
| 404 | $paymentMethod = $this->getPaymentMethod(); |
||
| 405 | if (!$paymentMethod) { |
||
| 406 | $paymentMethod = new PaymentMethod(); |
||
| 407 | $paymentMethod->populateFromApiResponse($data['paymentInfo'], (string)$data['currencyCode']); |
||
| 408 | } |
||
| 409 | $this->setPaymentMethod($paymentMethod); |
||
| 410 | |||
| 411 | // populate shipping info |
||
| 412 | $shippingMethod = $this->getShippingMethod(); |
||
| 413 | if (!$shippingMethod) { |
||
| 414 | $shippingMethod = new ShippingMethod(); |
||
| 415 | $shippingMethod->populateFromApiResponse($data['shippingInfo'], (string)$data['currencyCode']); |
||
| 416 | } |
||
| 417 | $this->setShippingMethod($shippingMethod); |
||
| 418 | |||
| 419 | // populate site |
||
| 420 | $site = $this->getSite(); |
||
| 421 | if (!$site) { |
||
| 422 | $site = new Site(); |
||
| 423 | $site->setExternalId($data['siteId']); |
||
| 424 | } |
||
| 425 | $this->setSite($site); |
||
| 426 | |||
| 427 | // populate state |
||
| 428 | $state = $this->getState(); |
||
| 429 | if (!$state) { |
||
| 430 | $state = new State(); |
||
| 431 | $state->populateFromApiResponse($data['orderState']); |
||
| 432 | } |
||
| 433 | $this->setState($state); |
||
| 434 | |||
| 435 | // @todo create order lines |
||
| 436 | } |
||
| 437 | |||
| 438 | return $this; |
||
| 439 | } |
||
| 440 | |||
| 441 | /** |
||
| 442 | * @return Money|null |
||
| 443 | */ |
||
| 444 | public function getTotalPrice() : ?Money |
||
| 445 | { |
||
| 446 | return $this->createMoney((int)$this->totalPrice); |
||
| 447 | } |
||
| 448 | |||
| 449 | /** |
||
| 450 | * @param Money $money |
||
| 451 | * @return OrderInterface |
||
| 452 | */ |
||
| 453 | public function setTotalPrice(Money $money = null) : OrderInterface |
||
| 454 | { |
||
| 455 | $this->totalPrice = $money->getAmount(); |
||
| 456 | |||
| 457 | return $this; |
||
| 458 | } |
||
| 459 | |||
| 460 | /** |
||
| 461 | * @return Money|null |
||
| 462 | */ |
||
| 463 | public function getSalesDiscount() : ?Money |
||
| 464 | { |
||
| 465 | return $this->createMoney((int)$this->salesDiscount); |
||
| 466 | } |
||
| 467 | |||
| 468 | /** |
||
| 469 | * @param Money $money |
||
| 470 | * @return OrderInterface |
||
| 471 | */ |
||
| 472 | public function setSalesDiscount(Money $money = null) : OrderInterface |
||
| 473 | { |
||
| 474 | $this->salesDiscount = $money->getAmount(); |
||
| 475 | |||
| 476 | return $this; |
||
| 477 | } |
||
| 478 | |||
| 479 | /** |
||
| 480 | * @return Money|null |
||
| 481 | */ |
||
| 482 | public function getGiftCertificateAmount() : ?Money |
||
| 483 | { |
||
| 484 | return $this->createMoney((int)$this->giftCertificateAmount); |
||
| 485 | } |
||
| 486 | |||
| 487 | /** |
||
| 488 | * @param Money $money |
||
| 489 | * @return OrderInterface |
||
| 490 | */ |
||
| 491 | public function setGiftCertificateAmount(Money $money = null) : OrderInterface |
||
| 492 | { |
||
| 493 | $this->giftCertificateAmount = $money->getAmount(); |
||
| 494 | |||
| 495 | return $this; |
||
| 496 | } |
||
| 497 | |||
| 498 | /** |
||
| 499 | * @return Money|null |
||
| 500 | */ |
||
| 501 | public function getShippingMethodFee() : ?Money |
||
| 502 | { |
||
| 503 | return $this->createMoney((int)$this->shippingMethodFee); |
||
| 504 | } |
||
| 505 | |||
| 506 | /** |
||
| 507 | * @param Money $money |
||
| 508 | * @return OrderInterface |
||
| 509 | */ |
||
| 510 | public function setShippingMethodFee(Money $money = null) : OrderInterface |
||
| 511 | { |
||
| 512 | $this->shippingMethodFee = $money->getAmount(); |
||
| 513 | |||
| 514 | return $this; |
||
| 515 | } |
||
| 516 | |||
| 517 | /** |
||
| 518 | * @return Money|null |
||
| 519 | */ |
||
| 520 | public function getPaymentMethodFee() : ?Money |
||
| 521 | { |
||
| 522 | return $this->createMoney((int)$this->paymentMethodFee); |
||
| 523 | } |
||
| 524 | |||
| 525 | /** |
||
| 526 | * @param Money $money |
||
| 527 | * @return OrderInterface |
||
| 528 | */ |
||
| 529 | public function setPaymentMethodFee(Money $money = null) : OrderInterface |
||
| 530 | { |
||
| 531 | $this->paymentMethodFee = $money->getAmount(); |
||
| 532 | |||
| 533 | return $this; |
||
| 534 | } |
||
| 535 | |||
| 536 | /** |
||
| 537 | * @return int |
||
| 538 | */ |
||
| 539 | public function getId(): int |
||
| 540 | { |
||
| 541 | return $this->id; |
||
| 542 | } |
||
| 543 | |||
| 544 | /** |
||
| 545 | * @param int $id |
||
| 546 | * @return OrderInterface |
||
| 547 | */ |
||
| 548 | public function setId($id) |
||
| 549 | { |
||
| 550 | $this->id = $id; |
||
| 551 | return $this; |
||
| 552 | } |
||
| 553 | |||
| 554 | /** |
||
| 555 | * @return int |
||
| 556 | */ |
||
| 557 | public function getExternalId(): int |
||
| 558 | { |
||
| 559 | return $this->externalId; |
||
| 560 | } |
||
| 561 | |||
| 562 | /** |
||
| 563 | * @param int $externalId |
||
| 564 | * @return OrderInterface |
||
| 565 | */ |
||
| 566 | public function setExternalId($externalId) |
||
| 567 | { |
||
| 568 | $this->externalId = $externalId; |
||
| 569 | return $this; |
||
| 570 | } |
||
| 571 | |||
| 572 | /** |
||
| 573 | * @return CustomerInterface|null |
||
| 574 | */ |
||
| 575 | public function getCustomer() |
||
| 576 | { |
||
| 577 | return $this->customer; |
||
| 578 | } |
||
| 579 | |||
| 580 | /** |
||
| 581 | * @param CustomerInterface|null $customer |
||
| 582 | * @return OrderInterface |
||
| 583 | */ |
||
| 584 | public function setCustomer($customer) |
||
| 585 | { |
||
| 586 | $this->customer = $customer; |
||
| 587 | return $this; |
||
| 588 | } |
||
| 589 | |||
| 590 | /** |
||
| 591 | * @return DeliveryInterface|null |
||
| 592 | */ |
||
| 593 | public function getDelivery() |
||
| 594 | { |
||
| 595 | return $this->delivery; |
||
| 596 | } |
||
| 597 | |||
| 598 | /** |
||
| 599 | * @param DeliveryInterface|null $delivery |
||
| 600 | * @return OrderInterface |
||
| 601 | */ |
||
| 602 | public function setDelivery($delivery) |
||
| 603 | { |
||
| 604 | $this->delivery = $delivery; |
||
| 605 | return $this; |
||
| 606 | } |
||
| 607 | |||
| 608 | /** |
||
| 609 | * @return InvoiceInterface|null |
||
| 610 | */ |
||
| 611 | public function getInvoice() |
||
| 612 | { |
||
| 613 | return $this->invoice; |
||
| 614 | } |
||
| 615 | |||
| 616 | /** |
||
| 617 | * @param InvoiceInterface|null $invoice |
||
| 618 | * @return OrderInterface |
||
| 619 | */ |
||
| 620 | public function setInvoice($invoice) |
||
| 621 | { |
||
| 622 | $this->invoice = $invoice; |
||
| 623 | return $this; |
||
| 624 | } |
||
| 625 | |||
| 626 | /** |
||
| 627 | * @return ArrayCollection|null |
||
| 628 | */ |
||
| 629 | public function getOrderLines() |
||
| 630 | { |
||
| 631 | return $this->orderLines; |
||
| 632 | } |
||
| 633 | |||
| 634 | /** |
||
| 635 | * @param ArrayCollection|null $orderLines |
||
| 636 | * @return OrderInterface |
||
| 637 | */ |
||
| 638 | public function setOrderLines($orderLines) |
||
| 639 | { |
||
| 640 | $this->orderLines = $orderLines; |
||
| 641 | return $this; |
||
| 642 | } |
||
| 643 | |||
| 644 | /** |
||
| 645 | * @return PaymentMethodInterface|null |
||
| 646 | */ |
||
| 647 | public function getPaymentMethod() |
||
| 648 | { |
||
| 649 | return $this->paymentMethod; |
||
| 650 | } |
||
| 651 | |||
| 652 | /** |
||
| 653 | * @param PaymentMethodInterface|null $paymentMethod |
||
| 654 | * @return OrderInterface |
||
| 655 | */ |
||
| 656 | public function setPaymentMethod($paymentMethod) |
||
| 657 | { |
||
| 658 | $this->paymentMethod = $paymentMethod; |
||
| 659 | return $this; |
||
| 660 | } |
||
| 661 | |||
| 662 | /** |
||
| 663 | * @return ShippingMethodInterface|null |
||
| 664 | */ |
||
| 665 | public function getShippingMethod() |
||
| 666 | { |
||
| 667 | return $this->shippingMethod; |
||
| 668 | } |
||
| 669 | |||
| 670 | /** |
||
| 671 | * @param ShippingMethodInterface|null $shippingMethod |
||
| 672 | * @return OrderInterface |
||
| 673 | */ |
||
| 674 | public function setShippingMethod($shippingMethod) |
||
| 675 | { |
||
| 676 | $this->shippingMethod = $shippingMethod; |
||
| 677 | return $this; |
||
| 678 | } |
||
| 679 | |||
| 680 | /** |
||
| 681 | * @return SiteInterface|null |
||
| 682 | */ |
||
| 683 | public function getSite() |
||
| 684 | { |
||
| 685 | return $this->site; |
||
| 686 | } |
||
| 687 | |||
| 688 | /** |
||
| 689 | * @param SiteInterface|null $site |
||
| 690 | * @return OrderInterface |
||
| 691 | */ |
||
| 692 | public function setSite($site) |
||
| 693 | { |
||
| 694 | $this->site = $site; |
||
| 695 | return $this; |
||
| 696 | } |
||
| 697 | |||
| 698 | /** |
||
| 699 | * @return StateInterface|null |
||
| 700 | */ |
||
| 701 | public function getState() |
||
| 702 | { |
||
| 703 | return $this->state; |
||
| 704 | } |
||
| 705 | |||
| 706 | /** |
||
| 707 | * @param StateInterface|null $state |
||
| 708 | * @return OrderInterface |
||
| 709 | */ |
||
| 710 | public function setState($state) |
||
| 711 | { |
||
| 712 | $this->state = $state; |
||
| 713 | return $this; |
||
| 714 | } |
||
| 715 | |||
| 716 | /** |
||
| 717 | * @return null|string |
||
| 718 | */ |
||
| 719 | public function getComment() |
||
| 720 | { |
||
| 721 | return $this->comment; |
||
| 722 | } |
||
| 723 | |||
| 724 | /** |
||
| 725 | * @param null|string $comment |
||
| 726 | * @return OrderInterface |
||
| 727 | */ |
||
| 728 | public function setComment($comment) |
||
| 729 | { |
||
| 730 | $this->comment = $comment; |
||
| 731 | return $this; |
||
| 732 | } |
||
| 733 | |||
| 734 | /** |
||
| 735 | * @return \DateTimeImmutable|null |
||
| 736 | */ |
||
| 737 | public function getCreatedDate() |
||
| 738 | { |
||
| 739 | return $this->createdDate; |
||
| 740 | } |
||
| 741 | |||
| 742 | /** |
||
| 743 | * @param \DateTimeImmutable|null $createdDate |
||
| 744 | * @return OrderInterface |
||
| 745 | */ |
||
| 746 | public function setCreatedDate($createdDate) |
||
| 747 | { |
||
| 748 | $this->createdDate = $createdDate; |
||
| 749 | return $this; |
||
| 750 | } |
||
| 751 | |||
| 752 | /** |
||
| 753 | * @return null|string |
||
| 754 | */ |
||
| 755 | public function getCreditNoteNumber() |
||
| 756 | { |
||
| 757 | return $this->creditNoteNumber; |
||
| 758 | } |
||
| 759 | |||
| 760 | /** |
||
| 761 | * @param null|string $creditNoteNumber |
||
| 762 | * @return Order |
||
| 763 | */ |
||
| 764 | public function setCreditNoteNumber($creditNoteNumber) |
||
| 765 | { |
||
| 766 | $this->creditNoteNumber = $creditNoteNumber; |
||
| 767 | return $this; |
||
| 768 | } |
||
| 769 | |||
| 770 | /** |
||
| 771 | * @return null|string |
||
| 772 | */ |
||
| 773 | public function getCurrencyCode() |
||
| 774 | { |
||
| 775 | return $this->currencyCode; |
||
| 776 | } |
||
| 777 | |||
| 778 | /** |
||
| 779 | * @param null|string $currencyCode |
||
| 780 | * @return OrderInterface |
||
| 781 | */ |
||
| 782 | public function setCurrencyCode($currencyCode) |
||
| 783 | { |
||
| 784 | $this->currencyCode = $currencyCode; |
||
| 785 | return $this; |
||
| 786 | } |
||
| 787 | |||
| 788 | /** |
||
| 789 | * @return null|string |
||
| 790 | */ |
||
| 791 | public function getCustomerComment() |
||
| 792 | { |
||
| 793 | return $this->customerComment; |
||
| 794 | } |
||
| 795 | |||
| 796 | /** |
||
| 797 | * @param null|string $customerComment |
||
| 798 | * @return OrderInterface |
||
| 799 | */ |
||
| 800 | public function setCustomerComment($customerComment) |
||
| 801 | { |
||
| 802 | $this->customerComment = $customerComment; |
||
| 803 | return $this; |
||
| 804 | } |
||
| 805 | |||
| 806 | /** |
||
| 807 | * @return null|string |
||
| 808 | */ |
||
| 809 | public function getGiftCertificateNumber() |
||
| 810 | { |
||
| 811 | return $this->giftCertificateNumber; |
||
| 812 | } |
||
| 813 | |||
| 814 | /** |
||
| 815 | * @param null|string $giftCertificateNumber |
||
| 816 | * @return OrderInterface |
||
| 817 | */ |
||
| 818 | public function setGiftCertificateNumber($giftCertificateNumber) |
||
| 819 | { |
||
| 820 | $this->giftCertificateNumber = $giftCertificateNumber; |
||
| 821 | return $this; |
||
| 822 | } |
||
| 823 | |||
| 824 | /** |
||
| 825 | * @return bool|null |
||
| 826 | */ |
||
| 827 | public function getIncomplete() |
||
| 828 | { |
||
| 829 | return $this->incomplete; |
||
| 830 | } |
||
| 831 | |||
| 832 | /** |
||
| 833 | * @param bool|null $incomplete |
||
| 834 | * @return OrderInterface |
||
| 835 | */ |
||
| 836 | public function setIncomplete($incomplete) |
||
| 837 | { |
||
| 838 | $this->incomplete = $incomplete; |
||
| 839 | return $this; |
||
| 840 | } |
||
| 841 | |||
| 842 | /** |
||
| 843 | * @return null|string |
||
| 844 | */ |
||
| 845 | public function getIp() |
||
| 846 | { |
||
| 847 | return $this->ip; |
||
| 848 | } |
||
| 849 | |||
| 850 | /** |
||
| 851 | * @param null|string $ip |
||
| 852 | * @return OrderInterface |
||
| 853 | */ |
||
| 854 | public function setIp($ip) |
||
| 855 | { |
||
| 856 | $this->ip = $ip; |
||
| 857 | return $this; |
||
| 858 | } |
||
| 859 | |||
| 860 | /** |
||
| 861 | * @return bool|null |
||
| 862 | */ |
||
| 863 | public function getModified() |
||
| 864 | { |
||
| 865 | return $this->modified; |
||
| 866 | } |
||
| 867 | |||
| 868 | /** |
||
| 869 | * @param bool|null $modified |
||
| 870 | * @return OrderInterface |
||
| 871 | */ |
||
| 872 | public function setModified($modified) |
||
| 873 | { |
||
| 874 | $this->modified = $modified; |
||
| 875 | return $this; |
||
| 876 | } |
||
| 877 | |||
| 878 | /** |
||
| 879 | * @return \DateTimeImmutable|null |
||
| 880 | */ |
||
| 881 | public function getModifiedDate() |
||
| 882 | { |
||
| 883 | return $this->modifiedDate; |
||
| 884 | } |
||
| 885 | |||
| 886 | /** |
||
| 887 | * @param \DateTimeImmutable|null $modifiedDate |
||
| 888 | * @return OrderInterface |
||
| 889 | */ |
||
| 890 | public function setModifiedDate($modifiedDate) |
||
| 894 | } |
||
| 895 | |||
| 896 | /** |
||
| 897 | * @return null|string |
||
| 898 | */ |
||
| 899 | public function getReferenceNumber() |
||
| 900 | { |
||
| 901 | return $this->referenceNumber; |
||
| 902 | } |
||
| 903 | |||
| 904 | /** |
||
| 905 | * @param null|string $referenceNumber |
||
| 906 | * @return OrderInterface |
||
| 907 | */ |
||
| 908 | public function setReferenceNumber($referenceNumber) |
||
| 909 | { |
||
| 910 | $this->referenceNumber = $referenceNumber; |
||
| 911 | return $this; |
||
| 912 | } |
||
| 913 | |||
| 914 | /** |
||
| 915 | * @return null|string |
||
| 916 | */ |
||
| 917 | public function getReferrer() |
||
| 918 | { |
||
| 919 | return $this->referrer; |
||
| 920 | } |
||
| 921 | |||
| 922 | /** |
||
| 923 | * @param null|string $referrer |
||
| 924 | * @return OrderInterface |
||
| 925 | */ |
||
| 926 | public function setReferrer($referrer) |
||
| 927 | { |
||
| 928 | $this->referrer = $referrer; |
||
| 929 | return $this; |
||
| 930 | } |
||
| 931 | |||
| 932 | /** |
||
| 933 | * @return null|string |
||
| 934 | */ |
||
| 935 | public function getReservedField1() |
||
| 936 | { |
||
| 937 | return $this->reservedField1; |
||
| 938 | } |
||
| 939 | |||
| 940 | /** |
||
| 941 | * @param null|string $reservedField1 |
||
| 942 | * @return OrderInterface |
||
| 943 | */ |
||
| 944 | public function setReservedField1($reservedField1) |
||
| 945 | { |
||
| 946 | $this->reservedField1 = $reservedField1; |
||
| 947 | return $this; |
||
| 948 | } |
||
| 949 | |||
| 950 | /** |
||
| 951 | * @return null|string |
||
| 952 | */ |
||
| 953 | public function getReservedField2() |
||
| 954 | { |
||
| 955 | return $this->reservedField2; |
||
| 956 | } |
||
| 957 | |||
| 958 | /** |
||
| 959 | * @param null|string $reservedField2 |
||
| 960 | * @return OrderInterface |
||
| 961 | */ |
||
| 962 | public function setReservedField2($reservedField2) |
||
| 963 | { |
||
| 964 | $this->reservedField2 = $reservedField2; |
||
| 965 | return $this; |
||
| 966 | } |
||
| 967 | |||
| 968 | /** |
||
| 969 | * @return null|string |
||
| 970 | */ |
||
| 971 | public function getReservedField3() |
||
| 972 | { |
||
| 973 | return $this->reservedField3; |
||
| 974 | } |
||
| 975 | |||
| 976 | /** |
||
| 977 | * @param null|string $reservedField3 |
||
| 978 | * @return OrderInterface |
||
| 979 | */ |
||
| 980 | public function setReservedField3($reservedField3) |
||
| 981 | { |
||
| 982 | $this->reservedField3 = $reservedField3; |
||
| 983 | return $this; |
||
| 984 | } |
||
| 985 | |||
| 986 | /** |
||
| 987 | * @return null|string |
||
| 988 | */ |
||
| 989 | public function getReservedField4() |
||
| 990 | { |
||
| 991 | return $this->reservedField4; |
||
| 992 | } |
||
| 993 | |||
| 994 | /** |
||
| 995 | * @param null|string $reservedField4 |
||
| 996 | * @return OrderInterface |
||
| 997 | */ |
||
| 998 | public function setReservedField4($reservedField4) |
||
| 999 | { |
||
| 1000 | $this->reservedField4 = $reservedField4; |
||
| 1001 | return $this; |
||
| 1002 | } |
||
| 1003 | |||
| 1004 | /** |
||
| 1005 | * @return null|string |
||
| 1006 | */ |
||
| 1007 | public function getReservedField5() |
||
| 1008 | { |
||
| 1009 | return $this->reservedField5; |
||
| 1010 | } |
||
| 1011 | |||
| 1012 | /** |
||
| 1013 | * @param null|string $reservedField5 |
||
| 1014 | * @return OrderInterface |
||
| 1015 | */ |
||
| 1016 | public function setReservedField5($reservedField5) |
||
| 1017 | { |
||
| 1018 | $this->reservedField5 = $reservedField5; |
||
| 1019 | return $this; |
||
| 1020 | } |
||
| 1021 | |||
| 1022 | /** |
||
| 1023 | * @return float|null |
||
| 1024 | */ |
||
| 1025 | public function getTotalWeight() |
||
| 1026 | { |
||
| 1027 | return $this->totalWeight; |
||
| 1028 | } |
||
| 1029 | |||
| 1030 | /** |
||
| 1031 | * @param float|null $totalWeight |
||
| 1032 | * @return OrderInterface |
||
| 1033 | */ |
||
| 1034 | public function setTotalWeight($totalWeight) |
||
| 1035 | { |
||
| 1036 | $this->totalWeight = $totalWeight; |
||
| 1037 | return $this; |
||
| 1038 | } |
||
| 1039 | |||
| 1040 | /** |
||
| 1041 | * @return null|string |
||
| 1042 | */ |
||
| 1043 | public function getTrackingNumber() |
||
| 1044 | { |
||
| 1045 | return $this->trackingNumber; |
||
| 1046 | } |
||
| 1047 | |||
| 1048 | /** |
||
| 1049 | * @param null|string $trackingNumber |
||
| 1050 | * @return OrderInterface |
||
| 1051 | */ |
||
| 1052 | public function setTrackingNumber($trackingNumber) |
||
| 1053 | { |
||
| 1054 | $this->trackingNumber = $trackingNumber; |
||
| 1055 | return $this; |
||
| 1056 | } |
||
| 1057 | |||
| 1058 | /** |
||
| 1059 | * @return int|null |
||
| 1060 | */ |
||
| 1061 | public function getTransactionNumber() |
||
| 1064 | } |
||
| 1065 | |||
| 1066 | /** |
||
| 1067 | * @param int|null $transactionNumber |
||
| 1068 | * @return OrderInterface |
||
| 1069 | */ |
||
| 1070 | public function setTransactionNumber($transactionNumber) |
||
| 1071 | { |
||
| 1072 | $this->transactionNumber = $transactionNumber; |
||
| 1073 | return $this; |
||
| 1074 | } |
||
| 1075 | |||
| 1076 | /** |
||
| 1077 | * @return float|null |
||
| 1078 | */ |
||
| 1079 | public function getVatPct() |
||
| 1082 | } |
||
| 1083 | |||
| 1084 | /** |
||
| 1085 | * @param float|null $vatPct |
||
| 1086 | * @return OrderInterface |
||
| 1087 | */ |
||
| 1088 | public function setVatPct($vatPct) |
||
| 1089 | { |
||
| 1090 | $this->vatPct = $vatPct; |
||
| 1091 | return $this; |
||
| 1092 | } |
||
| 1093 | |||
| 1094 | /** |
||
| 1095 | * @return null|string |
||
| 1096 | */ |
||
| 1097 | public function getVatRegNumber() |
||
| 1098 | { |
||
| 1099 | return $this->vatRegNumber; |
||
| 1100 | } |
||
| 1101 | |||
| 1102 | /** |
||
| 1103 | * @param null|string $vatRegNumber |
||
| 1104 | * @return OrderInterface |
||
| 1105 | */ |
||
| 1106 | public function setVatRegNumber($vatRegNumber) |
||
| 1107 | { |
||
| 1108 | $this->vatRegNumber = $vatRegNumber; |
||
| 1109 | return $this; |
||
| 1110 | } |
||
| 1111 | |||
| 1112 | /** |
||
| 1113 | * @return null|string |
||
| 1114 | */ |
||
| 1115 | public function getXmlParams() |
||
| 1116 | { |
||
| 1117 | return $this->xmlParams; |
||
| 1118 | } |
||
| 1119 | |||
| 1120 | /** |
||
| 1121 | * @param null|string $xmlParams |
||
| 1122 | * @return OrderInterface |
||
| 1123 | */ |
||
| 1124 | public function setXmlParams($xmlParams) |
||
| 1125 | { |
||
| 1126 | $this->xmlParams = $xmlParams; |
||
| 1127 | return $this; |
||
| 1128 | } |
||
| 1129 | |||
| 1130 | /** |
||
| 1131 | * A helper method for creating a Money object from a float based on the shared currency |
||
| 1132 | * |
||
| 1133 | * @param int $amount |
||
| 1134 | * @return Money|null |
||
| 1135 | */ |
||
| 1136 | private function createMoney(int $amount = 0) : ?Money |
||
| 1139 | } |
||
| 1140 | |||
| 1141 | /** |
||
| 1142 | * A helper method for creating a Money object from a float based on the shared currency |
||
| 1143 | * |
||
| 1144 | * @param float|string $amount |
||
| 1145 | * @return Money|null |
||
| 1146 | */ |
||
| 1147 | private function createMoneyFromFloat($amount = 0.0) : ?Money |
||
| 1148 | { |
||
| 1149 | return DandomainFoundation\createMoneyFromFloat((string)$this->currencyCode, $amount); |
||
| 1150 | } |
||
| 1151 | } |
||
| 1152 |