| 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 |
|
| 14 |
/** |
| 15 |
* Class Carrier. |
| 16 |
* |
| 17 |
* @package Packetery\EntityFactory |
| 18 |
*/ |
| 19 |
class Carrier { |
| 20 |
|
| 21 |
/** |
| 22 |
* Carrier factory. |
| 23 |
* |
| 24 |
* @param array $dbResult Data from db. |
| 25 |
* |
| 26 |
* @return Entity\Carrier |
| 27 |
*/ |
| 28 |
public function fromDbResult( array $dbResult ): Entity\Carrier { |
| 29 |
return new Entity\Carrier( |
| 30 |
$dbResult['id'], |
| 31 |
$dbResult['name'], |
| 32 |
(bool) $dbResult['is_pickup_points'], |
| 33 |
(bool) $dbResult['has_carrier_direct_label'], |
| 34 |
(bool) $dbResult['separate_house_number'], |
| 35 |
(bool) $dbResult['customs_declarations'], |
| 36 |
(bool) $dbResult['requires_email'], |
| 37 |
(bool) $dbResult['requires_phone'], |
| 38 |
(bool) $dbResult['requires_size'], |
| 39 |
! (bool) $dbResult['disallows_cod'], |
| 40 |
$dbResult['country'], |
| 41 |
$dbResult['currency'], |
| 42 |
(float) $dbResult['max_weight'], |
| 43 |
(bool) $dbResult['deleted'], |
| 44 |
false |
| 45 |
); |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Carrier factory. |
| 50 |
* |
| 51 |
* @param array $zpointCarrierData Data from db. |
| 52 |
* |
| 53 |
* @return Entity\Carrier |
| 54 |
*/ |
| 55 |
public function fromZpointCarrierData( array $zpointCarrierData ): Entity\Carrier { |
| 56 |
return new Entity\Carrier( |
| 57 |
(string) $zpointCarrierData['id'], |
| 58 |
$zpointCarrierData['name'], |
| 59 |
(bool) $zpointCarrierData['is_pickup_points'], |
| 60 |
false, |
| 61 |
false, |
| 62 |
false, |
| 63 |
false, |
| 64 |
false, |
| 65 |
false, |
| 66 |
true, |
| 67 |
$zpointCarrierData['country'], |
| 68 |
$zpointCarrierData['currency'], |
| 69 |
10, |
| 70 |
false, |
| 71 |
$zpointCarrierData['supports_age_verification'] |
| 72 |
); |
| 73 |
} |
| 74 |
} |
| 75 |
|