PluginProbe
Packeta / 2.1
Packeta v2.1
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
packeta / src / Packetery / Core / Entity / Carrier.php

Carrier.php in Packeta 2.1, at src/Packetery/Core/Entity/Carrier.php

330 lines 5.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class Carrier
4 *
5 * @package Packetery\Entities
6 */
7
8 declare( strict_types=1 );
9
10 namespace Packetery\Core\Entity;
11
12 /**
13 * Class Carrier
14 *
15 * @package Packetery\Entities
16 */
17 class Carrier {
18
19 public const INTERNAL_PICKUP_POINTS_ID = 'packeta';
20 public const VENDOR_GROUP_ZPOINT = 'zpoint';
21 public const VENDOR_GROUP_ZBOX = 'zbox';
22 public const ADDRESS_VALIDATION_COUNTRIES = [ 'cz', 'sk' ];
23 public const CAR_DELIVERY_CARRIERS = [ '25061' ];
24
25 /**
26 * Carrier id.
27 *
28 * @var string
29 */
30 private $id;
31
32 /**
33 * Carrier name.
34 *
35 * @var string
36 */
37 private $name;
38
39 /**
40 * Carrier hasPickupPoints.
41 *
42 * @var bool
43 */
44 private $hasPickupPoints;
45
46 /**
47 * Carrier hasDirectLabel.
48 *
49 * @var bool
50 */
51 private $hasDirectLabel;
52
53 /**
54 * Carrier requiresSeparateHouseNumber.
55 *
56 * @var bool
57 */
58 private $requiresSeparateHouseNumber;
59
60 /**
61 * Carrier requiresCustomsDeclarations.
62 *
63 * @var bool
64 */
65 private $requiresCustomsDeclarations;
66
67 /**
68 * Carrier requiresEmail.
69 *
70 * @var bool
71 */
72 private $requiresEmail;
73
74 /**
75 * Carrier requiresPhone.
76 *
77 * @var bool
78 */
79 private $requiresPhone;
80
81 /**
82 * Carrier requiresSize.
83 *
84 * @var bool
85 */
86 private $requiresSize;
87
88 /**
89 * Carrier supportsCod.
90 *
91 * @var bool
92 */
93 private $supportsCod;
94
95 /**
96 * Carrier country.
97 *
98 * @var string
99 */
100 private $country;
101
102 /**
103 * Carrier currency.
104 *
105 * @var string
106 */
107 private $currency;
108
109 /**
110 * Carrier maxWeight.
111 *
112 * @var float
113 */
114 private $maxWeight;
115
116 /**
117 * Tells if carrier is available.
118 *
119 * @var bool
120 */
121 private $isAvailable;
122
123 /**
124 * Carrier isDeleted.
125 *
126 * @var bool
127 */
128 private $isDeleted;
129
130 /**
131 * Carrier allows age verification.
132 *
133 * @var bool
134 */
135 private $ageVerification;
136
137 public function __construct(
138 string $id,
139 string $name,
140 bool $hasPickupPoints,
141 bool $hasDirectLabel,
142 bool $requiresSeparateHouseNumber,
143 bool $requiresCustomsDeclarations,
144 bool $requiresEmail,
145 bool $requiresPhone,
146 bool $requiresSize,
147 bool $supportsCod,
148 string $country,
149 string $currency,
150 float $maxWeight,
151 bool $isAvailable,
152 bool $isDeleted,
153 bool $ageVerification
154 ) {
155 $this->id = $id;
156 $this->name = $name;
157 $this->hasPickupPoints = $hasPickupPoints;
158 $this->hasDirectLabel = $hasDirectLabel;
159 $this->requiresSeparateHouseNumber = $requiresSeparateHouseNumber;
160 $this->requiresCustomsDeclarations = $requiresCustomsDeclarations;
161 $this->requiresEmail = $requiresEmail;
162 $this->requiresPhone = $requiresPhone;
163 $this->requiresSize = $requiresSize;
164 $this->supportsCod = $supportsCod;
165 $this->country = $country;
166 $this->currency = $currency;
167 $this->maxWeight = $maxWeight;
168 $this->isAvailable = $isAvailable;
169 $this->isDeleted = $isDeleted;
170 $this->ageVerification = $ageVerification;
171 }
172
173 /**
174 * Returns all properties as array.
175 *
176 * @return array<string, string|bool|float>
177 */
178 public function __toArray(): array {
179 return get_object_vars( $this );
180 }
181
182 /**
183 * Gets carrier id.
184 *
185 * @return string
186 */
187 public function getId(): string {
188 return $this->id;
189 }
190
191 /**
192 * Gets carrier name.
193 *
194 * @return string
195 */
196 public function getName(): string {
197 return $this->name;
198 }
199
200 /**
201 * Gets carrier hasPickupPoints.
202 *
203 * @return bool
204 */
205 public function hasPickupPoints(): bool {
206 return $this->hasPickupPoints;
207 }
208
209 /**
210 * Gets carrier hasCarrierDirectLabel.
211 *
212 * @return bool
213 */
214 public function hasDirectLabel(): bool {
215 return $this->hasDirectLabel;
216 }
217
218 /**
219 * Gets carrier separateHouseNumber.
220 *
221 * @return bool
222 */
223 public function requiresSeparateHouseNumber(): bool {
224 return $this->requiresSeparateHouseNumber;
225 }
226
227 /**
228 * Gets carrier customsDeclarations.
229 *
230 * @return bool
231 */
232 public function requiresCustomsDeclarations(): bool {
233 return $this->requiresCustomsDeclarations;
234 }
235
236 /**
237 * Gets carrier requiresEmail.
238 *
239 * @return bool
240 */
241 public function requiresEmail(): bool {
242 return $this->requiresEmail;
243 }
244
245 /**
246 * Gets carrier requiresPhone.
247 *
248 * @return bool
249 */
250 public function requiresPhone(): bool {
251 return $this->requiresPhone;
252 }
253
254 /**
255 * Gets carrier requiresSize.
256 *
257 * @return bool
258 */
259 public function requiresSize(): bool {
260 return $this->requiresSize;
261 }
262
263 /**
264 * Gets carrier supportsCod.
265 *
266 * @return bool
267 */
268 public function supportsCod(): bool {
269 return $this->supportsCod;
270 }
271
272 /**
273 * Gets carrier country.
274 *
275 * @return string
276 */
277 public function getCountry(): string {
278 return $this->country;
279 }
280
281 /**
282 * Gets carrier currency.
283 *
284 * @return string
285 */
286 public function getCurrency(): string {
287 return $this->currency;
288 }
289
290 /**
291 * Gets carrier maxWeight.
292 *
293 * @return float
294 */
295 public function getMaxWeight(): float {
296 return $this->maxWeight;
297 }
298
299 public function isAvailable(): bool {
300 return $this->isAvailable;
301 }
302
303 /**
304 * Gets carrier isDeleted.
305 *
306 * @return bool
307 */
308 public function isDeleted(): bool {
309 return $this->isDeleted;
310 }
311
312 /**
313 * Tells if allows age verification.
314 *
315 * @return bool
316 */
317 public function supportsAgeVerification(): bool {
318 return $this->ageVerification;
319 }
320
321 /**
322 * Tells if is car delivery carrier.
323 *
324 * @return bool
325 */
326 public function isCarDelivery(): bool {
327 return in_array( $this->id, self::CAR_DELIVERY_CARRIERS, true );
328 }
329 }
330