1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace VasilDakov\Speedy\Service\Shipment; |
6
|
|
|
|
7
|
|
|
use DateTime; |
8
|
|
|
use VasilDakov\Speedy\Speedy; |
9
|
|
|
use VasilDakov\Speedy\Traits\ToArray; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class ShipmentService |
13
|
|
|
* |
14
|
|
|
* @author Valentin Valkanov <[email protected]> |
15
|
|
|
* @author Vasil Dakov <[email protected]> |
16
|
|
|
* @copyright |
17
|
|
|
* @version |
18
|
|
|
*/ |
19
|
|
|
class ShipmentService |
20
|
|
|
{ |
21
|
|
|
use ToArray; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var DateTime|null |
25
|
|
|
*/ |
26
|
|
|
private ?DateTime $pickupDate = null; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var bool |
30
|
|
|
*/ |
31
|
|
|
private bool $autoAdjustPickupDate = false; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var int |
35
|
|
|
*/ |
36
|
|
|
private int $serviceId; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var ShipmentAdditionalServices|null |
40
|
|
|
*/ |
41
|
|
|
private ?ShipmentAdditionalServices $additionalServices = null; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var int|null |
45
|
|
|
*/ |
46
|
|
|
private ?int $deferredDays = null; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var bool |
50
|
|
|
*/ |
51
|
|
|
private bool $saturdayDelivery = false; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param int $serviceId |
55
|
|
|
*/ |
56
|
2 |
|
public function __construct(int $serviceId) |
57
|
|
|
{ |
58
|
2 |
|
$this->serviceId = $serviceId; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @return DateTime|null |
63
|
|
|
*/ |
64
|
|
|
public function getPickupDate(): ?DateTime |
65
|
|
|
{ |
66
|
|
|
return $this->pickupDate; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param DateTime $pickupDate |
71
|
|
|
* @return ShipmentService |
72
|
|
|
*/ |
73
|
1 |
|
public function setPickupDate(DateTime $pickupDate): self |
74
|
|
|
{ |
75
|
1 |
|
$this->pickupDate = $pickupDate; |
76
|
|
|
|
77
|
1 |
|
return $this; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return bool |
82
|
|
|
*/ |
83
|
|
|
public function isAutoAdjustPickupDate(): bool |
84
|
|
|
{ |
85
|
|
|
return $this->autoAdjustPickupDate; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param bool $autoAdjustPickupDate |
90
|
|
|
* @return ShipmentService |
91
|
|
|
*/ |
92
|
1 |
|
public function setAutoAdjustPickupDate(bool $autoAdjustPickupDate): self |
93
|
|
|
{ |
94
|
1 |
|
$this->autoAdjustPickupDate = $autoAdjustPickupDate; |
95
|
|
|
|
96
|
1 |
|
return $this; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @return int|null |
101
|
|
|
*/ |
102
|
1 |
|
public function getServiceId(): ?int |
103
|
|
|
{ |
104
|
1 |
|
return $this->serviceId; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @param int $serviceId |
109
|
|
|
*/ |
110
|
|
|
public function setServiceId(int $serviceId): void |
111
|
|
|
{ |
112
|
|
|
$this->serviceId = $serviceId; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @return ShipmentAdditionalServices|null |
117
|
|
|
*/ |
118
|
|
|
public function getAdditionalServices(): ?ShipmentAdditionalServices |
119
|
|
|
{ |
120
|
|
|
return $this->additionalServices; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @param ShipmentAdditionalServices $additionalServices |
125
|
|
|
* @return ShipmentService |
126
|
|
|
*/ |
127
|
1 |
|
public function setAdditionalServices(ShipmentAdditionalServices $additionalServices): self |
128
|
|
|
{ |
129
|
1 |
|
$this->additionalServices = $additionalServices; |
130
|
|
|
|
131
|
1 |
|
return $this; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @return int|null |
136
|
|
|
*/ |
137
|
|
|
public function getDeferredDays(): ?int |
138
|
|
|
{ |
139
|
|
|
return $this->deferredDays; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @param int $deferredDays |
144
|
|
|
* @return ShipmentService |
145
|
|
|
*/ |
146
|
1 |
|
public function setDeferredDays(int $deferredDays): self |
147
|
|
|
{ |
148
|
1 |
|
$this->deferredDays = $deferredDays; |
149
|
|
|
|
150
|
1 |
|
return $this; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @return bool |
155
|
|
|
*/ |
156
|
|
|
public function isSaturdayDelivery(): bool |
157
|
|
|
{ |
158
|
|
|
return $this->saturdayDelivery; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @param bool $saturdayDelivery |
163
|
|
|
* @return ShipmentService |
164
|
|
|
*/ |
165
|
1 |
|
public function setSaturdayDelivery(bool $saturdayDelivery): self |
166
|
|
|
{ |
167
|
1 |
|
$this->saturdayDelivery = $saturdayDelivery; |
168
|
|
|
|
169
|
1 |
|
return $this; |
170
|
|
|
} |
171
|
|
|
} |
172
|
|
|
|