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