PluginProbe
Packeta / 2.0.9
Packeta v2.0.9
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 / Module / EntityFactory / Carrier.php

Carrier.php in Packeta 2.0.9, at src/Packetery/Module/EntityFactory/Carrier.php

86 lines 1.9 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\EntityFactory
6 */
7
8 declare( strict_types=1 );
9
10 namespace Packetery\Module\EntityFactory;
11
12 use Packetery\Core\Entity;
13 use Packetery\Core\PickupPointProvider\BaseProvider;
14
15 /**
16 * Class Carrier.
17 *
18 * @package Packetery\EntityFactory
19 */
20 class Carrier {
21
22 /**
23 * An array of IDs of Carriers we want to add age verification check for
24 */
25 private const AGE_VERIFIED_CARRIERS = [
26 '106',
27 '131',
28 ];
29
30 /**
31 * Carrier factory.
32 *
33 * @param array<string, string> $dbResult Data from db.
34 *
35 * @return Entity\Carrier
36 */
37 public function fromDbResult( array $dbResult ): Entity\Carrier {
38 $ageVerified = in_array( $dbResult['id'], self::AGE_VERIFIED_CARRIERS, true );
39
40 return new Entity\Carrier(
41 $dbResult['id'],
42 $dbResult['name'],
43 (bool) $dbResult['is_pickup_points'],
44 (bool) $dbResult['has_carrier_direct_label'],
45 (bool) $dbResult['separate_house_number'],
46 (bool) $dbResult['customs_declarations'],
47 (bool) $dbResult['requires_email'],
48 (bool) $dbResult['requires_phone'],
49 (bool) $dbResult['requires_size'],
50 ! (bool) $dbResult['disallows_cod'],
51 $dbResult['country'],
52 $dbResult['currency'],
53 (float) $dbResult['max_weight'],
54 (bool) $dbResult['deleted'],
55 $ageVerified
56 );
57 }
58
59 /**
60 * Carrier factory.
61 *
62 * @param BaseProvider $nonFeedCarrierProvider Data from configuration.
63 *
64 * @return Entity\Carrier
65 */
66 public function fromNonFeedCarrierData( BaseProvider $nonFeedCarrierProvider ): Entity\Carrier {
67 return new Entity\Carrier(
68 $nonFeedCarrierProvider->getId(),
69 $nonFeedCarrierProvider->getName(),
70 $nonFeedCarrierProvider->hasPickupPoints(),
71 false,
72 false,
73 false,
74 false,
75 false,
76 false,
77 $nonFeedCarrierProvider->supportsCod(),
78 $nonFeedCarrierProvider->getCountry(),
79 $nonFeedCarrierProvider->getCurrency(),
80 10,
81 false,
82 $nonFeedCarrierProvider->supportsAgeVerification()
83 );
84 }
85 }
86