PluginProbe
Packeta / 1.6.3
Packeta v1.6.3
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 / CustomsDeclaration.php

CustomsDeclaration.php in Packeta 1.6.3, at src/Packetery/Module/EntityFactory/CustomsDeclaration.php

71 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class CustomsDeclaration.
4 *
5 * @package Packetery
6 */
7
8 declare(strict_types=1);
9
10 namespace Packetery\Module\EntityFactory;
11
12 use Packetery\Core\Entity;
13 use Packetery\Core\Helper;
14
15 /**
16 * Class CustomsDeclaration.
17 */
18 class CustomsDeclaration {
19
20 /**
21 * Creates customs declaration entity from standard structure.
22 *
23 * @param array $data Data.
24 * @param string $orderId Order ID.
25 *
26 * @return Entity\CustomsDeclaration
27 */
28 public function fromStandardizedStructure( array $data, string $orderId ): Entity\CustomsDeclaration {
29 $entity = new Entity\CustomsDeclaration(
30 $orderId,
31 $data['ead'],
32 (float) $data['delivery_cost'],
33 $data['invoice_number'],
34 \DateTimeImmutable::createFromFormat(
35 Helper::MYSQL_DATE_FORMAT,
36 $data['invoice_issue_date']
37 )
38 );
39 $entity->setId( $data['id'] ?? null );
40 $entity->setInvoiceFileId( $data['invoice_file_id'] );
41 $entity->setMrn( $data['mrn'] );
42 $entity->setEadFileId( $data['ead_file_id'] );
43
44 return $entity;
45 }
46
47 /**
48 * Creates item from standardized structure.
49 *
50 * @param array $data Data.
51 * @return Entity\CustomsDeclarationItem
52 */
53 public function createItemFromStandardizedStructure( array $data ): Entity\CustomsDeclarationItem {
54 $entity = new Entity\CustomsDeclarationItem(
55 $data['customs_declaration_id'],
56 $data['customs_code'],
57 (float) $data['value'],
58 $data['product_name_en'],
59 (int) $data['units_count'],
60 $data['country_of_origin'],
61 (float) $data['weight']
62 );
63 $entity->setId( $data['id'] ?? null );
64 $entity->setProductName( $data['product_name'] );
65 $entity->setIsFoodOrBook( (bool) ( $data['is_food_or_book'] ?? false ) );
66 $entity->setIsVoc( (bool) ( $data['is_voc'] ?? false ) );
67
68 return $entity;
69 }
70 }
71