PluginProbe
PostNL for WooCommerce / 4.4.1
PostNL for WooCommerce v4.4.1
5.9.12 5.9.11 5.9.10 5.9.9 5.9.8 5.9.7 5.9.6 trunk 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 3.1.4 3.1.5 3.1.6 3.1.7 4.0.0 4.0.1 4.0.2 4.3.2 4.3.3 4.4.0 4.4.1 All 72 releases
woo-postnl / vendor / myparcelnl / sdk / src / Adapter / DeliveryOptions / AbstractDeliveryOptionsAdapter.php

AbstractDeliveryOptionsAdapter.php in PostNL for WooCommerce 4.4.1, at vendor/myparcelnl/sdk/src/Adapter/DeliveryOptions/AbstractDeliveryOptionsAdapter.php

132 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php declare(strict_types=1);
2
3 namespace MyParcelNL\Sdk\src\Adapter\DeliveryOptions;
4
5 use MyParcelNL\Sdk\src\Model\Consignment\AbstractConsignment;
6
7 abstract class AbstractDeliveryOptionsAdapter
8 {
9 /**
10 * @var string
11 */
12 protected $date;
13
14 /**
15 * @var string
16 */
17 protected $deliveryType;
18
19 /**
20 * @var string
21 */
22 protected $packageType;
23
24 /**
25 * @var \MyParcelNL\Sdk\src\Adapter\DeliveryOptions\AbstractShipmentOptionsAdapter|null
26 */
27 protected $shipmentOptions;
28
29 /**
30 * @var string|null
31 */
32 protected $carrier;
33
34 /**
35 * @var \MyParcelNL\Sdk\src\Adapter\DeliveryOptions\AbstractPickupLocationAdapter
36 */
37 protected $pickupLocation;
38
39 /**
40 * @return string
41 */
42 public function getDate(): ?string
43 {
44 return $this->date;
45 }
46
47 /**
48 * @return string
49 */
50 public function getDeliveryType(): ?string
51 {
52 return $this->deliveryType;
53 }
54
55 /**
56 * @return string
57 */
58 public function getPackageType(): ?string
59 {
60 return $this->packageType;
61 }
62
63 /**
64 * @return int|null
65 */
66 public function getDeliveryTypeId(): ?int
67 {
68 if ($this->deliveryType === null) {
69 return null;
70 }
71
72 return AbstractConsignment::DELIVERY_TYPES_NAMES_IDS_MAP[$this->deliveryType];
73 }
74
75 /**
76 * @return AbstractShipmentOptionsAdapter|null
77 */
78 public function getShipmentOptions(): ?AbstractShipmentOptionsAdapter
79 {
80 return $this->shipmentOptions;
81 }
82
83 /**
84 * @return string
85 */
86 public function getCarrier(): ?string
87 {
88 return $this->carrier;
89 }
90
91 /**
92 * @return \MyParcelNL\Sdk\src\Adapter\DeliveryOptions\AbstractPickupLocationAdapter|null
93 */
94 public function getPickupLocation(): ?AbstractPickupLocationAdapter
95 {
96 return $this->pickupLocation;
97 }
98
99 /**
100 * @return bool
101 */
102 public function isPickup(): bool
103 {
104 if ($this->deliveryType === null) {
105 return false;
106 }
107
108 return in_array(
109 $this->deliveryType, [
110 AbstractConsignment::DELIVERY_TYPE_PICKUP_NAME,
111 AbstractConsignment::DELIVERY_TYPE_PICKUP_EXPRESS_NAME,
112 ]
113 );
114 }
115
116 /**
117 * @return array
118 */
119 public function toArray(): array
120 {
121 return [
122 "carrier" => $this->getCarrier(),
123 "date" => $this->getDate(),
124 "deliveryType" => $this->getDeliveryType(),
125 "packageType" => $this->getPackageType(),
126 "isPickup" => $this->isPickup(),
127 "pickupLocation" => $this->getPickupLocation() ? $this->getPickupLocation()->toArray() : null,
128 "shipmentOptions" => $this->getShipmentOptions() ? $this->getShipmentOptions()->toArray() : null,
129 ];
130 }
131 }
132